kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 10/11] Virt: support XEN via libvirt and auto url installer
Date: Tue, 11 Oct 2011 18:07:16 -0300	[thread overview]
Message-ID: <1318367237-26081-11-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1318367237-26081-1-git-send-email-lmr@redhat.com>

From: Cleber Rosa <crosa@redhat.com>

This patchs adds proper detection of active (alive) XEN domains via libvirt;
a quick way to determine whether the current connected hypervisor is XEN or
QEMU/KVM and also deals with virt-install options and syntax supported on
RHEL 5 libvirt+XEN.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 client/virt/libvirt_vm.py |   54 ++++++++++++++++++++++++++++----------------
 1 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/client/virt/libvirt_vm.py b/client/virt/libvirt_vm.py
index bed512f..e536b5b 100644
--- a/client/virt/libvirt_vm.py
+++ b/client/virt/libvirt_vm.py
@@ -104,8 +104,8 @@ def virsh_is_dead(name):
 
     @param name: VM name
     """
-    if (virsh_domstate(name) == 'running' or
-        virsh_domstate(name) == 'idle'):
+    state = virsh_domstate(name)
+    if state in ('running', 'idle', 'no state'):
         return False
     else:
         return True
@@ -250,6 +250,15 @@ def virsh_domain_exists(name):
         logging.warning("VM %s does not exist", name)
         return False
 
+VIRSH_DEFAULT_URI = virsh_uri()
+LIBVIRT_QEMU = False
+LIBVIRT_XEN = False
+
+if VIRSH_DEFAULT_URI == 'qemu:///system':
+    LIBVIRT_QEMU = True
+elif VIRSH_DEFAULT_URI == 'xen:///':
+    LIBVIRT_XEN = True
+
 
 class VM(virt_vm.BaseVM):
     """
@@ -410,7 +419,6 @@ class VM(virt_vm.BaseVM):
             return " --vcpu=%s" % smp
 
         def add_location(help, location):
-            #return " --location %s" % location
             if has_option(help, "location"):
                 return " --location %s" % location
             else:
@@ -563,7 +571,9 @@ class VM(virt_vm.BaseVM):
         # TODO: directory location for vmlinuz/kernel for cdrom install ?
         location = None
         if params.get("medium") == 'url':
-            location = params.get("url")
+            if params.get("url") == 'auto':
+                location = params.get('auto_content_url')
+
         elif params.get("medium") == 'kernel_initrd':
             # directory location of kernel/initrd pair (directory layout must
             # be in format libvirt will recognize)
@@ -634,19 +644,20 @@ class VM(virt_vm.BaseVM):
                                   image_params.get("drive_cache"),
                                   image_params.get("image_format"))
 
-        for cdrom in params.objects("cdroms"):
-            cdrom_params = params.object_params(cdrom)
-            iso = cdrom_params.get("cdrom")
-            if params.get("use_libvirt_cdrom_switch") == 'yes':
-                # we don't want to skip the winutils iso
-                if not cdrom == 'winutils':
-                    logging.debug("Using --cdrom instead of --disk for install")
-                    logging.debug("Skipping CDROM:%s:%s", cdrom, iso)
-                    continue
-            if params.get("medium") == 'cdrom_no_kernel_initrd':
-                if iso == params.get("cdrom_cd1"):
-                    logging.debug("Using cdrom or url for install")
-                    logging.debug("Skipping CDROM: %s", iso)
+        if LIBVIRT_QEMU:
+            for cdrom in params.objects("cdroms"):
+                cdrom_params = params.object_params(cdrom)
+                iso = cdrom_params.get("cdrom")
+                if params.get("use_libvirt_cdrom_switch") == 'yes':
+                    # we don't want to skip the winutils iso
+                    if not cdrom == 'winutils':
+                        logging.debug("Using --cdrom instead of --disk for install")
+                        logging.debug("Skipping CDROM:%s:%s", cdrom, iso)
+                        continue
+                if params.get("medium") == 'cdrom_no_kernel_initrd':
+                    if iso == params.get("cdrom_cd1"):
+                        logging.debug("Using cdrom or url for install")
+                        logging.debug("Skipping CDROM: %s", iso)
                     continue
 
             if iso:
@@ -685,9 +696,12 @@ class VM(virt_vm.BaseVM):
             virt_install_cmd += " --mac %s" % mac
             self.nic_mac = mac
 
-        virt_install_cmd += (" --network %s,model=%s" %
-                             (params.get("virsh_network"),
-                              params.get("nic_model")))
+        if LIBVIRT_XEN:
+            virt_install_cmd += (" --network=%s" % params.get("virsh_network"))
+        elif LIBVIRT_QEMU:
+            virt_install_cmd += (" --network=%s,model=%s" %
+                                 (params.get("virsh_network"),
+                                  params.get("nic_model")))
 
         if params.get("use_no_reboot") == "yes":
             virt_install_cmd += " --noreboot"
-- 
1.7.6.4

  parent reply	other threads:[~2011-10-11 21:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-11 21:07 [PATCH 00/11] [RFC] Libvirt test v2 Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 02/11] virt: Introducing virt_test.virt_test class Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 03/11] Moving unattended_install test from kvm test to common virt location Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 04/11] Moving get_started code to client.virt.virt_utils Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 05/11] virt: Introducing libvirt VM class Lucas Meneghel Rodrigues
2011-10-12  6:51   ` [Autotest] " Amos Kong
2011-10-12  8:14   ` Daniel P. Berrange
2011-10-13 17:26     ` Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 06/11] virt: Introducing libvirt monitor Lucas Meneghel Rodrigues
2011-10-12  7:48   ` [Autotest] " Amos Kong
2011-10-13 17:12     ` Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 07/11] virt.virt_env_process: Add libvirt vm handling Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 08/11] client.tests: Introducing libvirt test Lucas Meneghel Rodrigues
2011-10-11 21:07 ` [PATCH 09/11] Virt: builtin HTTP server for unattended installs Lucas Meneghel Rodrigues
2011-10-11 21:07 ` Lucas Meneghel Rodrigues [this message]
2011-10-11 21:07 ` [PATCH 11/11] Virt: add support for XEN via libvirt installs and auto url Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1318367237-26081-11-git-send-email-lmr@redhat.com \
    --to=lmr@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).