]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain: Convert os.type to VIR_DOMAIN_OSTYPE enum
authorCole Robinson <crobinso@redhat.com>
Fri, 17 Apr 2015 00:11:06 +0000 (20:11 -0400)
committerCole Robinson <crobinso@redhat.com>
Mon, 20 Apr 2015 20:40:09 +0000 (16:40 -0400)
33 files changed:
src/conf/capabilities.c
src/conf/capabilities.h
src/conf/domain_audit.c
src/conf/domain_conf.c
src/conf/domain_conf.h
src/hyperv/hyperv_driver.c
src/libxl/libxl_conf.c
src/libxl/libxl_domain.c
src/libxl/libxl_driver.c
src/lxc/lxc_driver.c
src/lxc/lxc_native.c
src/openvz/openvz_conf.c
src/openvz/openvz_driver.c
src/parallels/parallels_driver.c
src/parallels/parallels_sdk.c
src/parallels/parallels_utils.h
src/phyp/phyp_driver.c
src/qemu/qemu_capabilities.c
src/qemu/qemu_command.c
src/qemu/qemu_driver.c
src/uml/uml_driver.c
src/vbox/vbox_common.c
src/vmware/vmware_driver.c
src/vmx/vmx.c
src/xen/xen_driver.c
src/xen/xend_internal.c
src/xenapi/xenapi_driver.c
src/xenapi/xenapi_utils.c
src/xenconfig/xen_common.c
src/xenconfig/xen_sxpr.c
src/xenconfig/xen_xl.c
src/xenconfig/xen_xm.c
tests/openvzutilstest.c

index a8b098ae510d81cd3b296245de32ebe3cc6041f0..deae4724df6d060b7342df8d478e3b7bb97136e0 100644 (file)
@@ -593,23 +593,16 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps,
 /**
  * virCapabilitiesSupportsGuestOSType:
  * @caps: capabilities to query
- * @ostype: OS type to search for (eg 'hvm', 'xen')
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
  *
  * Returns non-zero if the capabilities support the
  * requested operating system type
  */
 extern int
 virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
-                                   const char *ostypestr)
+                                   int ostype)
 {
     size_t i;
-    int ostype;
-
-    if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown OS type '%s'"), ostypestr);
-        return 0;
-    }
 
     for (i = 0; i < caps->nguests; i++) {
         if (caps->guests[i]->ostype == ostype)
@@ -622,7 +615,7 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
 /**
  * virCapabilitiesSupportsGuestOSTypeArch:
  * @caps: capabilities to query
- * @ostype: OS type to search for (eg 'hvm', 'xen')
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
  * @arch: Architecture to search for
  *
  * Returns non-zero if the capabilities support the
@@ -630,17 +623,10 @@ virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
  */
 extern int
 virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
-                                       const char *ostypestr,
+                                       int ostype,
                                        virArch arch)
 {
     size_t i;
-    int ostype;
-
-    if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown OS type '%s'"), ostypestr);
-        return 0;
-    }
 
     for (i = 0; i < caps->nguests; i++) {
         if (caps->guests[i]->ostype == ostype &&
@@ -654,24 +640,17 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
 /**
  * virCapabilitiesDefaultGuestArch:
  * @caps: capabilities to query
- * @ostype: OS type to search for
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
  *
  * Returns the first architecture able to run the
  * requested operating system type
  */
 extern virArch
 virCapabilitiesDefaultGuestArch(virCapsPtr caps,
-                                const char *ostypestr,
+                                int ostype,
                                 const char *domain)
 {
     size_t i, j;
-    int ostype;
-
-    if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown OS type '%s'"), ostypestr);
-        return VIR_ARCH_NONE;
-    }
 
     /* First try to find one matching host arch */
     for (i = 0; i < caps->nguests; i++) {
@@ -700,7 +679,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps,
 /**
  * virCapabilitiesDefaultGuestMachine:
  * @caps: capabilities to query
- * @ostype: OS type to search for
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
  * @arch: architecture to search for
  * @domain: domain type to search for
  *
@@ -710,18 +689,11 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps,
  */
 extern const char *
 virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
-                                   const char *ostypestr,
+                                   int ostype,
                                    virArch arch,
                                    const char *domain)
 {
     size_t i;
-    int ostype;
-
-    if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown OS type '%s'"), ostypestr);
-        return NULL;
-    }
 
     for (i = 0; i < caps->nguests; i++) {
         virCapsGuestPtr guest = caps->guests[i];
@@ -753,7 +725,7 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
 /**
  * virCapabilitiesDefaultGuestEmulator:
  * @caps: capabilities to query
- * @ostype: OS type to search for ('xen', 'hvm')
+ * @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
  * @arch: architecture to search for
  * @domain: domain type ('xen', 'qemu', 'kvm')
  *
@@ -763,18 +735,11 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
  */
 extern const char *
 virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
-                                    const char *ostypestr,
+                                    int ostype,
                                     virArch arch,
                                     const char *domain)
 {
     size_t i, j;
-    int ostype;
-
-    if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("unknown OS type '%s'"), ostypestr);
-        return NULL;
-    }
 
     for (i = 0; i < caps->nguests; i++) {
         char *emulator;
index 9312cc2fb0106ef525815d30bfa0a639771eafd5..8969a978734f5efd1cec79d0b9ceb8ebe24e547f 100644 (file)
@@ -267,10 +267,10 @@ virCapabilitiesSupportsGuestArch(virCapsPtr caps,
                                  virArch arch);
 extern int
 virCapabilitiesSupportsGuestOSType(virCapsPtr caps,
-                                   const char *ostype);
+                                   int ostype);
 extern int
 virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps,
-                                       const char *ostype,
+                                       int ostype,
                                        virArch arch);
 
 void
@@ -279,16 +279,16 @@ virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPUPtr cpu,
 
 extern virArch
 virCapabilitiesDefaultGuestArch(virCapsPtr caps,
-                                const char *ostype,
+                                int ostype,
                                 const char *domain);
 extern const char *
 virCapabilitiesDefaultGuestMachine(virCapsPtr caps,
-                                   const char *ostype,
+                                   int ostype,
                                    virArch arch,
                                    const char *domain);
 extern const char *
 virCapabilitiesDefaultGuestEmulator(virCapsPtr caps,
-                                    const char *ostype,
+                                    int ostype,
                                     virArch arch,
                                     const char *domain);
 
index 159ebf5a71e748e887023121940a79ccaa4e5607..3e93d97d5b7e2b65d1d964645480b9fed5596de4 100644 (file)
@@ -859,7 +859,7 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success)
         if (i == 0 &&
             (vm->def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
              vm->def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
-             STREQ_NULLABLE(vm->def->os.type, "hvm"))
+             vm->def->os.type == VIR_DOMAIN_OSTYPE_HVM)
             continue;
 
         virDomainAuditChardev(vm, NULL, vm->def->consoles[i], "start", true);
index 8731fc1f9cd1ba875590d7b533f1102bb204d991..727d0606f8d0be353b130835ca909a3058d48c43 100644 (file)
@@ -2276,7 +2276,6 @@ void virDomainDefFree(virDomainDefPtr def)
     VIR_FREE(def->idmap.uidmap);
     VIR_FREE(def->idmap.gidmap);
 
-    VIR_FREE(def->os.type);
     VIR_FREE(def->os.machine);
     VIR_FREE(def->os.init);
     for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
@@ -3065,7 +3064,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
             i == 0 &&
             (def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
              def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
-             STREQ_NULLABLE(def->os.type, "hvm"))
+             def->os.type == VIR_DOMAIN_OSTYPE_HVM)
             continue;
         device.data.chr = def->consoles[i];
         if (cb(def, &device, &def->consoles[i]->info, opaque) < 0)
@@ -3299,14 +3298,8 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
 {
     size_t i;
 
-    if (!def->os.type) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("hypervisor type must be specified"));
-        return -1;
-    }
-
     /* verify init path for container based domains */
-    if (STREQ(def->os.type, "exe") && !def->os.init) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("init binary must be specified"));
         return -1;
@@ -3384,7 +3377,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
             return -1;
         }
     }
-    if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") &&
+    if (def->nconsoles > 0 && def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
         (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
          def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) {
 
@@ -9451,7 +9444,7 @@ virDomainInputDefParseXML(const virDomainDef *dom,
             goto error;
         }
 
-        if (STREQ(dom->os.type, "hvm")) {
+        if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
             if (def->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
                 def->type != VIR_DOMAIN_INPUT_TYPE_MOUSE &&
                 def->type != VIR_DOMAIN_INPUT_TYPE_KBD) {
@@ -9466,7 +9459,7 @@ virDomainInputDefParseXML(const virDomainDef *dom,
                                bus);
                 goto error;
             }
-        } else if (STREQ(dom->os.type, "xen")) {
+        } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN) {
             if (def->bus != VIR_DOMAIN_INPUT_BUS_XEN) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("unsupported input bus %s"),
@@ -9506,7 +9499,7 @@ virDomainInputDefParseXML(const virDomainDef *dom,
             }
         }
     } else {
-        if (STREQ(dom->os.type, "hvm")) {
+        if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
             if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
                 def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
                 (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
@@ -9514,7 +9507,7 @@ virDomainInputDefParseXML(const virDomainDef *dom,
             } else {
                 def->bus = VIR_DOMAIN_INPUT_BUS_USB;
             }
-        } else if (STREQ(dom->os.type, "xen")) {
+        } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN) {
             def->bus = VIR_DOMAIN_INPUT_BUS_XEN;
         } else {
             if ((dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
@@ -10989,9 +10982,8 @@ virDomainVideoDefaultType(const virDomainDef *def)
     case VIR_DOMAIN_VIRT_KQEMU:
     case VIR_DOMAIN_VIRT_KVM:
     case VIR_DOMAIN_VIRT_XEN:
-        if (def->os.type &&
-            (STREQ(def->os.type, "xen") ||
-             STREQ(def->os.type, "linux")))
+        if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+            def->os.type == VIR_DOMAIN_OSTYPE_LINUX)
             return VIR_DOMAIN_VIDEO_TYPE_XEN;
         else if ARCH_IS_PPC64(def->os.arch)
             return VIR_DOMAIN_VIDEO_TYPE_VGA;
@@ -11005,15 +10997,10 @@ virDomainVideoDefaultType(const virDomainDef *def)
         return VIR_DOMAIN_VIDEO_TYPE_VMVGA;
 
     case VIR_DOMAIN_VIRT_PARALLELS:
-        if (def->os.type) {
-            if (STREQ(def->os.type, "hvm"))
-                return VIR_DOMAIN_VIDEO_TYPE_VGA;
-            else
-                return VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
-        } else {
+        if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
             return VIR_DOMAIN_VIDEO_TYPE_VGA;
-        }
-
+        else
+            return VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
     default:
         return -1;
     }
@@ -12992,7 +12979,8 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr def,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("no emulator for domain %s os type %s "
                          "on architecture %s"),
-                       type, def->os.type, virArchToString(def->os.arch));
+                       type, virDomainOSTypeToString(def->os.type),
+                       virArchToString(def->os.arch));
         return NULL;
     }
 
@@ -14640,27 +14628,32 @@ virDomainDefParseXML(xmlDocPtr xml,
     def->os.bootloader = virXPathString("string(./bootloader)", ctxt);
     def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt);
 
-    def->os.type = virXPathString("string(./os/type[1])", ctxt);
-    if (!def->os.type) {
+    tmp = virXPathString("string(./os/type[1])", ctxt);
+    if (!tmp) {
         if (def->os.bootloader) {
-            if (VIR_STRDUP(def->os.type, "xen") < 0)
-                goto error;
+            def->os.type = VIR_DOMAIN_OSTYPE_XEN;
         } else {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("an os <type> must be specified"));
             goto error;
         }
+    } else {
+        if ((def->os.type = virDomainOSTypeFromString(tmp)) < 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("unknown OS type '%s'"), tmp);
+            goto error;
+        }
+        VIR_FREE(tmp);
     }
+
     /*
      * HACK: For xen driver we previously used bogus 'linux' as the
      * os type for paravirt, whereas capabilities declare it to
      * be 'xen'. So we accept the former and convert
      */
-    if (STREQ(def->os.type, "linux") &&
+    if (def->os.type == VIR_DOMAIN_OSTYPE_LINUX &&
         def->virtType == VIR_DOMAIN_VIRT_XEN) {
-        VIR_FREE(def->os.type);
-        if (VIR_STRDUP(def->os.type, "xen") < 0)
-            goto error;
+        def->os.type = VIR_DOMAIN_OSTYPE_XEN;
     }
 
     tmp = virXPathString("string(./os/type[1]/@arch)", ctxt);
@@ -14678,7 +14671,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("no support found for os <type> '%s'"),
-                           def->os.type);
+                           virDomainOSTypeToString(def->os.type));
             goto error;
         }
 
@@ -14695,7 +14688,8 @@ virDomainDefParseXML(xmlDocPtr xml,
                                                         def->os.arch)) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("No os type '%s' available for arch '%s'"),
-                               def->os.type, virArchToString(def->os.arch));
+                               virDomainOSTypeToString(def->os.type),
+                               virArchToString(def->os.arch));
                 goto error;
             }
         } else {
@@ -14706,7 +14700,7 @@ virDomainDefParseXML(xmlDocPtr xml,
             if (!def->os.arch) {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("no supported architecture for os type '%s'"),
-                               def->os.type);
+                               virDomainOSTypeToString(def->os.type));
                 goto error;
             }
         }
@@ -14731,7 +14725,7 @@ virDomainDefParseXML(xmlDocPtr xml,
      *   - An init script                             (exe)
      */
 
-    if (STREQ(def->os.type, "exe")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
         def->os.init = virXPathString("string(./os/init[1])", ctxt);
         def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
 
@@ -14755,9 +14749,9 @@ virDomainDefParseXML(xmlDocPtr xml,
         VIR_FREE(nodes);
     }
 
-    if (STREQ(def->os.type, "xen") ||
-        STREQ(def->os.type, "hvm") ||
-        STREQ(def->os.type, "uml")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+        def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
+        def->os.type == VIR_DOMAIN_OSTYPE_UML) {
         xmlNodePtr loader_node;
 
         def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
@@ -14777,7 +14771,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         }
     }
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (virDomainDefParseBootXML(ctxt, def) < 0)
             goto error;
         if (!(bootHash = virHashCreate(5, NULL)))
@@ -15055,15 +15049,15 @@ virDomainDefParseXML(xmlDocPtr xml,
         /* With QEMU / KVM / Xen graphics, mouse + PS/2 is implicit
          * with graphics, so don't store it.
          * XXX will this be true for other virt types ? */
-        if ((STREQ(def->os.type, "hvm") &&
+        if ((def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
              input->bus == VIR_DOMAIN_INPUT_BUS_PS2 &&
              (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
               input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) ||
-            (STREQ(def->os.type, "xen") &&
+            (def->os.type == VIR_DOMAIN_OSTYPE_XEN &&
              input->bus == VIR_DOMAIN_INPUT_BUS_XEN &&
              (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
               input->type == VIR_DOMAIN_INPUT_TYPE_KBD)) ||
-            (STREQ(def->os.type, "exe") &&
+            (def->os.type == VIR_DOMAIN_OSTYPE_EXE &&
              def->virtType == VIR_DOMAIN_VIRT_PARALLELS &&
              input->bus == VIR_DOMAIN_INPUT_BUS_PARALLELS &&
              (input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
@@ -15097,9 +15091,9 @@ virDomainDefParseXML(xmlDocPtr xml,
         (ARCH_IS_X86(def->os.arch) || def->os.arch == VIR_ARCH_NONE)) {
         int input_bus = VIR_DOMAIN_INPUT_BUS_XEN;
 
-        if (STREQ(def->os.type, "hvm"))
+        if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
             input_bus = VIR_DOMAIN_INPUT_BUS_PS2;
-        if (STREQ(def->os.type, "exe") &&
+        if (def->os.type == VIR_DOMAIN_OSTYPE_EXE &&
             def->virtType == VIR_DOMAIN_VIRT_PARALLELS)
             input_bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
 
@@ -16795,10 +16789,11 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
         goto error;
     }
 
-    if (STRNEQ(src->os.type, dst->os.type)) {
+    if (src->os.type != dst->os.type) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Target domain OS type %s does not match source %s"),
-                       dst->os.type, src->os.type);
+                       virDomainOSTypeToString(dst->os.type),
+                       virDomainOSTypeToString(src->os.type));
         goto error;
     }
     if (src->os.arch != dst->os.arch) {
@@ -16810,8 +16805,8 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
     }
     if (STRNEQ_NULLABLE(src->os.machine, dst->os.machine)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target domain OS type %s does not match source %s"),
-                       dst->os.machine, src->os.machine);
+                    _("Target domain machine type %s does not match source %s"),
+                    dst->os.machine, src->os.machine);
         goto error;
     }
 
@@ -20819,10 +20814,12 @@ virDomainDefFormatInternal(virDomainDefPtr def,
      * be 'xen'. So we convert to the former for backcompat
      */
     if (def->virtType == VIR_DOMAIN_VIRT_XEN &&
-        STREQ(def->os.type, "xen"))
-        virBufferAsprintf(buf, ">%s</type>\n", "linux");
+        def->os.type == VIR_DOMAIN_OSTYPE_XEN)
+        virBufferAsprintf(buf, ">%s</type>\n",
+                          virDomainOSTypeToString(VIR_DOMAIN_OSTYPE_LINUX));
     else
-        virBufferAsprintf(buf, ">%s</type>\n", def->os.type);
+        virBufferAsprintf(buf, ">%s</type>\n",
+                          virDomainOSTypeToString(def->os.type));
 
     virBufferEscapeString(buf, "<init>%s</init>\n",
                           def->os.init);
@@ -21194,7 +21191,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         /* Back compat, ignore the console element for hvm guests
          * if it is type == serial
          */
-        if (STREQ(def->os.type, "hvm") &&
+        if (def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
             (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL ||
              def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) &&
             (n < def->nserials)) {
@@ -21207,7 +21204,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         if (virDomainChrDefFormat(buf, &console, flags) < 0)
             goto error;
     }
-    if (STREQ(def->os.type, "hvm") &&
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
         def->nconsoles == 0 &&
         def->nserials > 0) {
         virDomainChrDef console;
@@ -21240,9 +21237,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                 .info = { .alias = NULL },
             };
 
-            if (STREQ(def->os.type, "hvm"))
+            if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
                 autoInput.bus = VIR_DOMAIN_INPUT_BUS_PS2;
-            else if (STREQ(def->os.type, "exe") &&
+            else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE &&
                      def->virtType == VIR_DOMAIN_VIRT_PARALLELS)
                 autoInput.bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
             else
@@ -21479,7 +21476,7 @@ virDomainDefCompatibleDevice(virDomainDefPtr def,
         return 0;
 
     if (!virDomainDefHasUSB(def) &&
-        STRNEQ(def->os.type, "exe") &&
+        def->os.type != VIR_DOMAIN_OSTYPE_EXE &&
         virDomainDeviceIsUSB(dev)) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("Device configuration is not compatible: "
index 6dc9918f97ddb50df448af4df194d95dfe21a6f9..3c990198e2d52e330e8bcd51e39fea606a5436ce 100644 (file)
@@ -1783,7 +1783,7 @@ void virDomainLoaderDefFree(virDomainLoaderDefPtr loader);
 typedef struct _virDomainOSDef virDomainOSDef;
 typedef virDomainOSDef *virDomainOSDefPtr;
 struct _virDomainOSDef {
-    char *type;
+    int type;
     virArch arch;
     char *machine;
     size_t nBootDevs;
index 00169c7d31f892fefc2e88e7a5693001c6d74b07..b5395412750726b43da0774a909d754bf4a76fd9 100644 (file)
@@ -875,9 +875,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 
     def->vcpus = processorSettingData->data->VirtualQuantity;
     def->maxvcpus = processorSettingData->data->VirtualQuantity;
-
-    if (VIR_STRDUP(def->os.type, "hvm") < 0)
-        goto cleanup;
+    def->os.type = VIR_DOMAIN_OSTYPE_HVM;
 
     /* FIXME: devices section is totally missing */
 
index 0609fdd12724009f3dc5188feb6749fd486e6935..322dd560938df908809dd423b292debd157e8bb5 100644 (file)
@@ -499,7 +499,7 @@ libxlMakeDomCreateInfo(libxl_ctx *ctx,
 
     libxl_domain_create_info_init(c_info);
 
-    if (STREQ(def->os.type, "hvm"))
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
         c_info->type = LIBXL_DOMAIN_TYPE_HVM;
     else
         c_info->type = LIBXL_DOMAIN_TYPE_PV;
@@ -625,7 +625,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
                       libxl_domain_config *d_config)
 {
     libxl_domain_build_info *b_info = &d_config->b_info;
-    int hvm = STREQ(def->os.type, "hvm");
+    int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     size_t i;
 
     libxl_domain_build_info_init(b_info);
@@ -875,7 +875,7 @@ libxlDomainGetEmulatorType(const virDomainDef *def)
     virCommandPtr cmd = NULL;
     char *output = NULL;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (def->emulator) {
             cmd = virCommandNew(def->emulator);
 
@@ -1070,7 +1070,7 @@ libxlMakeNic(virDomainDefPtr def,
              virDomainNetDefPtr l_nic,
              libxl_device_nic *x_nic)
 {
-    bool ioemu_nic = STREQ(def->os.type, "hvm");
+    bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virDomainNetType actual_type = virDomainNetGetActualType(l_nic);
 
     /* TODO: Where is mtu stored?
@@ -1309,7 +1309,7 @@ libxlMakeVfbList(virPortAllocatorPtr graphicsports,
      * VNC or SDL info must also be set in libxl_domain_build_info
      * for HVM domains.  Use the first vfb device.
      */
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         libxl_domain_build_info *b_info = &d_config->b_info;
         libxl_device_vfb vfb = d_config->vfbs[0];
 
index 77d46d022947b0e6cd5531b1cf4336a38e08a6f4..f33df427df414de8579017b12430d243593009ef 100644 (file)
@@ -235,7 +235,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
     if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
         dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
         dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
-        STRNEQ(def->os.type, "hvm"))
+        def->os.type != VIR_DOMAIN_OSTYPE_HVM)
         dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
 
     if (dev->type == VIR_DOMAIN_DEVICE_NET &&
@@ -278,7 +278,7 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
             pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
     }
 
-    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && STREQ(def->os.type, "hvm")) {
+    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         int dm_type = libxlDomainGetEmulatorType(def);
 
         switch (dev->data.video->type) {
@@ -315,7 +315,7 @@ libxlDomainDefPostParse(virDomainDefPtr def,
 {
     /* Xen PV domains always have a PV console, so add one to the domain config
      * via post-parse callback if not explicitly specified in the XML. */
-    if (STRNEQ(def->os.type, "hvm") && def->nconsoles == 0) {
+    if (def->os.type != VIR_DOMAIN_OSTYPE_HVM && def->nconsoles == 0) {
         virDomainChrDefPtr chrdef;
 
         if (!(chrdef = virDomainChrDefNew()))
index 9eb071e8a0b26d4e51e0f37c5eee0f89df593dea..1271149a59683fa36204d86d057bd74eef241474 100644 (file)
@@ -1295,7 +1295,7 @@ libxlDomainGetOSType(virDomainPtr dom)
     if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (VIR_STRDUP(type, vm->def->os.type) < 0)
+    if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
         goto cleanup;
 
  cleanup:
index 8dfa686eb4e59ae0a6884c7cd4e7eee5d6bd4e5d..b491f341f472f79fcc75e6e57a025cbdb63e3a07 100644 (file)
@@ -665,7 +665,7 @@ static char *lxcDomainGetOSType(virDomainPtr dom)
     if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (VIR_STRDUP(ret, vm->def->os.type) < 0)
+    if (VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)) < 0)
         goto cleanup;
 
  cleanup:
index c15eb19f3dd50036ee0e603783779a1534941762..25d53837574bd0bbd3312a2fbfa0cb67e5331803 100644 (file)
@@ -1025,9 +1025,7 @@ lxcParseConfigString(const char *config)
     vmdef->vcpus = 1;
 
     vmdef->nfss = 0;
-
-    if (VIR_STRDUP(vmdef->os.type, "exe") < 0)
-        goto error;
+    vmdef->os.type = VIR_DOMAIN_OSTYPE_EXE;
 
     if ((value = virConfGetValue(properties, "lxc.arch")) && value->str) {
         virArch arch = virArchFromString(value->str);
index 80df15abafb2df256e5ff268cccd0d91367bf222..a2d2da797aaca77ac171b7e168735f3153e75cd3 100644 (file)
@@ -564,8 +564,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
             goto cleanup;
         }
 
-        if (VIR_STRDUP(def->os.type, "exe") < 0)
-            goto cleanup;
+        def->os.type = VIR_DOMAIN_OSTYPE_EXE;
         if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
             goto cleanup;
 
index f9f924fe1d29f0eb52a1af1756026281d55f8d8d..f07337a37ac97d34e1dc1a4f1d447cdad304bbdd 100644 (file)
@@ -92,7 +92,7 @@ openvzDomainDefPostParse(virDomainDefPtr def,
                          void *opaque ATTRIBUTE_UNUSED)
 {
     /* fill the init path */
-    if (STREQ(def->os.type, "exe") && !def->os.init) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_EXE && !def->os.init) {
         if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
             return -1;
     }
@@ -371,7 +371,7 @@ static char *openvzDomainGetOSType(virDomainPtr dom)
         goto cleanup;
     }
 
-    ignore_value(VIR_STRDUP(ret, vm->def->os.type));
+    ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)));
 
  cleanup:
     if (vm)
index d80fe24cebd03688c3a6e0ca08348cfe0c26fa74..a654861c3a5d47b4a77a77dd4660dd5ad0d9a75a 100644 (file)
@@ -184,7 +184,7 @@ parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         (dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
          dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
         !dev->data.net->model &&
-        STREQ(def->os.type, "hvm") &&
+        def->os.type == VIR_DOMAIN_OSTYPE_HVM &&
         VIR_STRDUP(dev->data.net->model, "e1000") < 0)
         goto cleanup;
 
@@ -575,7 +575,7 @@ parallelsDomainGetOSType(virDomainPtr domain)
         goto cleanup;
     }
 
-    ignore_value(VIR_STRDUP(ret, privdom->def->os.type));
+    ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(privdom->def->os.type)));
 
  cleanup:
     if (privdom)
@@ -712,15 +712,16 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int
     olddom = virDomainObjListFindByUUID(privconn->domains, def->uuid);
     if (olddom == NULL) {
         virResetLastError();
-        if (STREQ(def->os.type, "hvm")) {
+        if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
             if (prlsdkCreateVm(conn, def))
                 goto cleanup;
-        } else if (STREQ(def->os.type, "exe")) {
+        } else if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
             if (prlsdkCreateCt(conn, def))
                 goto cleanup;
         } else {
             virReportError(VIR_ERR_INVALID_ARG,
-                           _("Unsupported OS type: %s"), def->os.type);
+                           _("Unsupported OS type: %s"),
+                           virDomainOSTypeToString(def->os.type));
             goto cleanup;
         }
 
index 72c1773c2ae3ad8589b957ef46c42ef5765f2ac4..59ca62e432b811a07516550e368c28e96a15005b 100644 (file)
@@ -1174,12 +1174,10 @@ prlsdkConvertDomainType(PRL_HANDLE sdkdom, virDomainDefPtr def)
 
     switch (domainType) {
     case PVT_VM:
-        if (VIR_STRDUP(def->os.type, "hvm") < 0)
-            return -1;
+        def->os.type = VIR_DOMAIN_OSTYPE_HVM;
         break;
     case PVT_CT:
-        if (VIR_STRDUP(def->os.type, "exe") < 0)
-            return -1;
+        def->os.type = VIR_DOMAIN_OSTYPE_EXE;
         if (VIR_STRDUP(def->os.init, "/sbin/init") < 0)
             return -1;
         break;
index 0f29374986a4f96c02e540c7b70b439df3f5922c..573138191205f7a7c90f8065b13aa73b3f8d8901 100644 (file)
@@ -37,7 +37,7 @@
     virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__,    \
                      __FUNCTION__, __LINE__, _("Can't parse prlctl output"))
 
-# define IS_CT(def)  (STREQ_NULLABLE(def->os.type, "exe"))
+# define IS_CT(def)  (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
 
 # define parallelsDomNotFoundError(domain)                               \
     do {                                                                 \
index a6b96de11b04c783a73694a9a34ec4e7c35f177a..6e177b02df0266832702eef1509406e7ed75c9f3 100644 (file)
@@ -1720,8 +1720,7 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml)
     if (domain_name == NULL)
         goto cleanup;
 
-    if (VIR_STRDUP(def->os.type, "aix") < 0)
-        goto cleanup;
+    def->os.type = VIR_DOMAIN_OSTYPE_AIX;
 
     dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL,
                                   VIR_DOMAIN_DEF_PARSE_INACTIVE);
index 960645919b050e0c995ab353afa016743142a4f9..afeeddf4f269a1c8c68bc70ce326fcff6fe92ccb 100644 (file)
@@ -1897,7 +1897,7 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
 
     hostarch = virArchFromHost();
     if ((binary = virCapabilitiesDefaultGuestEmulator(caps,
-                                                      "hvm",
+                                                      VIR_DOMAIN_OSTYPE_HVM,
                                                       hostarch,
                                                       "qemu")) == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
index e7e093738ebbd9abcf543d4c42f0e56323f42b72..886bba463a3e0e09b98bcf7a83604dced20a5568 100644 (file)
@@ -8834,8 +8834,8 @@ qemuBuildCommandLine(virConnectPtr conn,
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_UUID))
         virCommandAddArgList(cmd, "-uuid", uuid, NULL);
     if (def->virtType == VIR_DOMAIN_VIRT_XEN ||
-        STREQ(def->os.type, "xen") ||
-        STREQ(def->os.type, "linux")) {
+        def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+        def->os.type == VIR_DOMAIN_OSTYPE_LINUX) {
         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_XEN_DOMID)) {
             virCommandAddArg(cmd, "-xen-attach");
             virCommandAddArg(cmd, "-xen-domid");
@@ -12315,11 +12315,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
 
     if (strstr(path, "xenner")) {
         def->virtType = VIR_DOMAIN_VIRT_KVM;
-        if (VIR_STRDUP(def->os.type, "xen") < 0)
-            goto error;
+        def->os.type = VIR_DOMAIN_OSTYPE_XEN;
     } else {
-        if (VIR_STRDUP(def->os.type, "hvm") < 0)
-            goto error;
+        def->os.type = VIR_DOMAIN_OSTYPE_HVM;
         if (strstr(path, "kvm")) {
             def->virtType = VIR_DOMAIN_VIRT_KVM;
             def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON;
index b3816eec9ac6e6d76866dac4ff2c8397b6c6272b..0f1667885b7f632271d42a10a0c4c41c29d59567 100644 (file)
@@ -2241,7 +2241,7 @@ static char *qemuDomainGetOSType(virDomainPtr dom) {
     if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    ignore_value(VIR_STRDUP(type, vm->def->os.type));
+    ignore_value(VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)));
 
  cleanup:
     qemuDomObjEndAPI(&vm);
index 6b4f655fb8bb2ec558bc6185e1b50b728d8c658a..674470221a990484f30583383513a1b5eb07aae5 100644 (file)
@@ -1773,7 +1773,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) {
     if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
         goto cleanup;
 
-    if (VIR_STRDUP(type, vm->def->os.type) < 0)
+    if (VIR_STRDUP(type, virDomainOSTypeToString(vm->def->os.type)) < 0)
         goto cleanup;
 
  cleanup:
index 710c50fef04a527b19c51b90a3c66e098ec41fe2..b419ddcea2ae8643bd43206c9ad1fdd84520873c 100644 (file)
@@ -930,7 +930,7 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data,
     PRUint32 maxBootPosition            = 0;
     size_t i = 0;
 
-    VIR_DEBUG("def->os.type             %s", def->os.type);
+    VIR_DEBUG("def->os.type             %s", virDomainOSTypeToString(def->os.type));
     VIR_DEBUG("def->os.arch             %s", virArchToString(def->os.arch));
     VIR_DEBUG("def->os.machine          %s", def->os.machine);
     VIR_DEBUG("def->os.nBootDevs        %zu", def->os.nBootDevs);
@@ -3906,9 +3906,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
 
     /* Skip cpumasklen, cpumask, onReboot, onPoweroff, onCrash */
 
-    if (VIR_STRDUP(def->os.type, "hvm") < 0)
-        goto cleanup;
-
+    def->os.type = VIR_DOMAIN_OSTYPE_HVM;
     def->os.arch = virArchFromHost();
 
     def->os.nBootDevs = 0;
@@ -4122,8 +4120,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
     if (!(def = virDomainDefNew()))
         return ret;
 
-    if (VIR_STRDUP(def->os.type, "hvm") < 0)
-        goto cleanup;
+    def->os.type = VIR_DOMAIN_OSTYPE_HVM;
 
     dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt,
                                   VIR_DOMAIN_DEF_PARSE_INACTIVE);
@@ -4254,8 +4251,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml)
     if (!(def = virDomainDefNew()))
         return ret;
 
-    if (VIR_STRDUP(def->os.type, "hvm") < 0)
-        goto cleanup;
+    def->os.type = VIR_DOMAIN_OSTYPE_HVM;
 
     dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt,
                                   VIR_DOMAIN_DEF_PARSE_INACTIVE);
@@ -6061,8 +6057,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
          * reading and while dumping xml
          */
         virDomainDefSetMemoryInitial(def->dom, memorySize * 1024);
-        if (VIR_STRDUP(def->dom->os.type, "hvm") < 0)
-            goto cleanup;
+        def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM;
         def->dom->os.arch = virArchFromHost();
         gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount);
         def->dom->maxvcpus = def->dom->vcpus = CPUCount;
index 33829947b65c56e68451bb23e2509fcbbb650331..6967dbc1342e45d3a7c12eab2f3a3b2d31353e20 100644 (file)
@@ -870,7 +870,7 @@ vmwareDomainGetOSType(virDomainPtr dom)
         goto cleanup;
     }
 
-    ignore_value(VIR_STRDUP(ret, vm->def->os.type));
+    ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)));
 
  cleanup:
     if (vm)
index 8b814367b49d2dcdf003a4a00db864225bc03a13..cacc951fa21e9b1f34e3b5e75dc673385614cdf0 100644 (file)
@@ -1522,8 +1522,7 @@ virVMXParseConfig(virVMXContext *ctx,
     def->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
 
     /* def:os */
-    if (VIR_STRDUP(def->os.type, "hvm") < 0)
-        goto cleanup;
+    def->os.type = VIR_DOMAIN_OSTYPE_HVM;
 
     /* vmx:guestOS -> def:os.arch */
     if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0)
index 3b11e9a4c36fb21137dbf14c06153c984555e408..6cd3b76e9d0b24f7881e658c05f9e7c2db097040 100644 (file)
@@ -338,7 +338,7 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
     if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
         dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
         dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
-        STRNEQ(def->os.type, "hvm"))
+        def->os.type != VIR_DOMAIN_OSTYPE_HVM)
         dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
 
     /* forbid capabilities mode hostdev in this kind of hypervisor */
index 3813900f685c247b4fa56dc349b38058bdf5b349..99dfdcbf7b7bb4bf4af8d2c0039f9e1bdca17e1a 100644 (file)
@@ -2261,7 +2261,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
     case VIR_DOMAIN_DEVICE_DISK:
         if (xenFormatSxprDisk(dev->data.disk,
                               &buf,
-                              STREQ(def->os.type, "hvm") ? 1 : 0,
+                              def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
                               priv->xendConfigVersion, 1) < 0)
             goto cleanup;
 
@@ -2274,7 +2274,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
         if (xenFormatSxprNet(conn,
                              dev->data.net,
                              &buf,
-                             STREQ(def->os.type, "hvm") ? 1 : 0,
+                             def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
                              priv->xendConfigVersion, 1) < 0)
             goto cleanup;
 
@@ -2409,7 +2409,7 @@ xenDaemonUpdateDeviceFlags(virConnectPtr conn,
     case VIR_DOMAIN_DEVICE_DISK:
         if (xenFormatSxprDisk(dev->data.disk,
                               &buf,
-                              STREQ(def->os.type, "hvm") ? 1 : 0,
+                              def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
                               priv->xendConfigVersion, 1) < 0)
             goto cleanup;
         break;
index 2ec0b6541f68070df5889b98617593c46671e9c2..6b2e5ee3db352c28da6077c203e8bce2ac061b27 100644 (file)
@@ -52,7 +52,7 @@ xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
     if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
         dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
         dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
-        STRNEQ(def->os.type, "hvm"))
+        def->os.type != VIR_DOMAIN_OSTYPE_HVM)
         dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
 
     /* forbid capabilities mode hostdev in this kind of hypervisor */
@@ -1427,10 +1427,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
         goto error;
     xen_vm_get_hvm_boot_policy(session, &boot_policy, vm);
     if (STREQ(boot_policy, "BIOS order")) {
-        if (VIR_STRDUP(defPtr->os.type, "hvm") < 0) {
-            VIR_FREE(boot_policy);
-            goto error;
-        }
+        defPtr->os.type = VIR_DOMAIN_OSTYPE_HVM;
         xen_vm_get_hvm_boot_params(session, &result, vm);
         if (result != NULL) {
             size_t i;
@@ -1450,10 +1447,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
         VIR_FREE(boot_policy);
     } else {
         char *value = NULL;
-        if (VIR_STRDUP(defPtr->os.type, "xen") < 0) {
-            VIR_FREE(boot_policy);
-            goto error;
-        }
+        defPtr->os.type = VIR_DOMAIN_OSTYPE_XEN;
         if (VIR_ALLOC(defPtr->os.loader) < 0 ||
             VIR_STRDUP(defPtr->os.loader->path, "pygrub") < 0) {
             VIR_FREE(boot_policy);
index ce952608a1dc489d94e1984c758f075515e29713..a80e084ea19f8aae8d78c6ac5c8d8b737a3c1f22 100644 (file)
@@ -464,7 +464,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
     virUUIDFormat(def->uuid, uuidStr);
     if (VIR_STRDUP((*record)->uuid, uuidStr) < 0)
         goto error;
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         char *boot_order = NULL;
         if (VIR_STRDUP((*record)->hvm_boot_policy, "BIOS order") < 0)
             goto error;
@@ -476,7 +476,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
             (*record)->hvm_boot_params = hvm_boot_params;
             VIR_FREE(boot_order);
         }
-    } else if (STREQ(def->os.type, "xen")) {
+    } else if (def->os.type == VIR_DOMAIN_OSTYPE_XEN) {
         if (VIR_STRDUP((*record)->pv_bootloader, "pygrub") < 0)
             goto error;
         if (def->os.kernel) {
index 7ae2d4acdd7fe5f2946743a880e217ec5662cba1..48484d6403de7d54bdc12dcb76a5bbebb7e04102 100644 (file)
@@ -331,7 +331,7 @@ xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def,
     if (xenConfigGetBool(conf, "localtime", &vmlocaltime, 0) < 0)
         return -1;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         /* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */
         if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
             if (vmlocaltime)
@@ -513,7 +513,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
     if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0))
         return -1;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetBool(conf, "pae", &val, 1) < 0)
             return -1;
 
@@ -570,7 +570,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 {
     int val;
     char *listenAddr = NULL;
-    int hvm = STREQ(def->os.type, "hvm");
+    int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virConfValuePtr list;
     virDomainGraphicsDefPtr graphics = NULL;
 
@@ -724,7 +724,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def)
     virConfValuePtr value = NULL;
     virDomainChrDefPtr chr = NULL;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetString(conf, "parallel", &str, NULL) < 0)
             goto cleanup;
         if (str && STRNEQ(str, "none") &&
@@ -967,7 +967,7 @@ xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
 {
     const char *str;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0)
             return -1;
 
@@ -997,8 +997,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
         STREQ(str, "hvm"))
         hvm = 1;
 
-    if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
-        return -1;
+    def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN);
 
     def->os.arch =
         virCapabilitiesDefaultGuestArch(caps,
@@ -1007,7 +1006,7 @@ xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
     if (!def->os.arch) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("no supported architecture for os type '%s'"),
-                       def->os.type);
+                       virDomainOSTypeToString(def->os.type));
         return -1;
     }
 
@@ -1346,7 +1345,7 @@ xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
         }
 
     } else {
-        if (STREQ(def->os.type, "hvm")) {
+        if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
             /* >=3.1 HV: VARIABLE */
             int rtc_timeoffset;
 
@@ -1447,7 +1446,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def)
 {
     size_t i;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (def->nparallels) {
             virBuffer buf = VIR_BUFFER_INITIALIZER;
             char *str;
@@ -1565,7 +1564,7 @@ xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion
 {
     size_t i;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigSetInt(conf, "pae",
                             (def->features[VIR_DOMAIN_FEATURE_PAE] ==
                             VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
@@ -1621,7 +1620,7 @@ xenFormatCDROM(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 {
     size_t i;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
             for (i = 0; i < def->ndisks; i++) {
                 if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
@@ -1644,7 +1643,7 @@ xenFormatCDROM(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 static int
 xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 {
-    int hvm = STREQ(def->os.type, "hvm") ? 1 : 0;
+    int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0;
 
     if (def->ngraphics == 1 &&
         def->graphics[0]->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
@@ -1763,7 +1762,7 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 static int
 xenFormatSound(virConfPtr conf, virDomainDefPtr def)
 {
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (def->sounds) {
             virBuffer buf = VIR_BUFFER_INITIALIZER;
             char *str = NULL;
@@ -1792,7 +1791,7 @@ xenFormatVif(virConfPtr conf,
 {
    virConfValuePtr netVal = NULL;
    size_t i;
-   int hvm = STREQ(def->os.type, "hvm");
+   int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
 
    if (VIR_ALLOC(netVal) < 0)
         goto cleanup;
index d77abf3a6e283d577f3e77876035dc99f11b380d..5f58fd8ac04f881d45f981c14e758f0d902b59a7 100644 (file)
@@ -1145,8 +1145,7 @@ xenParseSxpr(const struct sexpr *root,
             goto error;
     }
 
-    if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "linux") < 0)
-        goto error;
+    def->os.type = (hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_LINUX);
 
     if (def->id != 0) {
         if (sexpr_lookup(root, "domain/image")) {
@@ -2273,7 +2272,7 @@ xenFormatSxpr(virConnectPtr conn,
     }
     virBufferAsprintf(&buf, "(on_crash '%s')", tmp);
 
-    if (STREQ(def->os.type, "hvm"))
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM)
         hvm = 1;
 
     if (!def->os.bootloader) {
index 62284f79212f862a1598ccd7a77087582deac290..db554b2ab373cc7211a82abf398cf127341cc4a7 100644 (file)
@@ -64,7 +64,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
     size_t i;
     const char *extra, *root;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         const char *boot;
 
         for (i = 0; i < caps->nguests; i++) {
@@ -159,7 +159,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
     char *listenAddr = NULL;
     int val;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetBool(conf, "spice", &val, 0) < 0)
             return -1;
 
@@ -353,7 +353,8 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
                 }
             }
 
-            if (STRPREFIX(libxldisk->vdev, "xvd") || !STREQ(def->os.type, "hvm"))
+            if (STRPREFIX(libxldisk->vdev, "xvd") ||
+                def->os.type != VIR_DOMAIN_OSTYPE_HVM)
                 disk->bus = VIR_DOMAIN_DISK_BUS_XEN;
             else if (STRPREFIX(libxldisk->vdev, "sd"))
                 disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
@@ -388,7 +389,7 @@ xenParseXLInputDevs(virConfPtr conf, virDomainDefPtr def)
     const char *str;
     virConfValuePtr val;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         val = virConfGetValue(conf, "usbdevice");
         /* usbdevice can be defined as either a single string or a list */
         if (val && val->type == VIR_CONF_LIST) {
@@ -475,7 +476,7 @@ xenFormatXLOS(virConfPtr conf, virDomainDefPtr def)
 {
     size_t i;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         char boot[VIR_DOMAIN_BOOT_LAST+1];
         if (xenConfigSetString(conf, "builder", "hvm") < 0)
             return -1;
@@ -667,7 +668,7 @@ xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def)
 {
     const char *listenAddr = NULL;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
             /* set others to false but may not be necessary */
             if (xenConfigSetInt(conf, "sdl", 0) < 0)
@@ -726,7 +727,7 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr def)
     const char *devtype;
     virConfValuePtr usbdevices = NULL, lastdev;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (VIR_ALLOC(usbdevices) < 0)
             goto error;
 
index ba10fb978afbc46729aca88b96bc4d5b1ec65dd6..fafe66243191e32256dcef4dbc3c4f50da409ed9 100644 (file)
@@ -42,7 +42,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
 {
     size_t i;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         const char *boot;
 
         if (VIR_ALLOC(def->os.loader) < 0 ||
@@ -108,7 +108,7 @@ xenParseXMDisk(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 {
     const char *str = NULL;
     virDomainDiskDefPtr disk = NULL;
-    int hvm = STREQ(def->os.type, "hvm");
+    int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virConfValuePtr list = virConfGetValue(conf, "disk");
 
     if (list && list->type == VIR_CONF_LIST) {
@@ -391,7 +391,7 @@ xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
 {
     virConfValuePtr diskVal = NULL;
     size_t i = 0;
-    int hvm = STREQ(def->os.type, "hvm");
+    int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
 
     if (VIR_ALLOC(diskVal) < 0)
         goto cleanup;
@@ -436,7 +436,7 @@ xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def)
 {
     const char *str;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0)
             return -1;
         if (str &&
@@ -503,7 +503,7 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def)
 {
     size_t i;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         char boot[VIR_DOMAIN_BOOT_LAST+1];
         if (xenConfigSetString(conf, "builder", "hvm") < 0)
             return -1;
@@ -573,7 +573,7 @@ xenFormatXMInputDevs(virConfPtr conf, virDomainDefPtr def)
     size_t i;
     const char *devtype;
 
-    if (STREQ(def->os.type, "hvm")) {
+    if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
         for (i = 0; i < def->ninputs; i++) {
             if (def->inputs[i]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
                 if (xenConfigSetInt(conf, "usb", 1) < 0)
index f9d10020a55a4083798aa307f56226ae97eb7ff3..1414d703f77cffb6eebe4561de8a83f88e4c6267 100644 (file)
@@ -103,11 +103,11 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
         "</domain>\n";
 
     if (!(def = virDomainDefNew()) ||
-        VIR_STRDUP(def->os.type, "exe") < 0 ||
         VIR_STRDUP(def->os.init, "/sbin/init") < 0)
         goto cleanup;
 
     def->virtType = VIR_DOMAIN_VIRT_OPENVZ;
+    def->os.type = VIR_DOMAIN_OSTYPE_EXE;
 
     if (openvzReadNetworkConf(def, 1) < 0) {
         err = virGetLastError();