[PATCH 03/10] conf: Set default scsi controller model when parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And adding controller implicitly, ESX detects the default model
automatically itself, and partly depends on the guest os. So we
only try to set the default model for QEMU/KVM driver.
---
 src/conf/domain_conf.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2da41f8..ccdb80d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2502,6 +2502,28 @@ virDomainParseLegacyDeviceAddress(char *devaddr,
     return 0;
 }
 
+static int
+virDomainControllerDefaultModel(virDomainDefPtr def,
+                                int type)
+{
+    switch(def->virtType) {
+    case VIR_DOMAIN_VIRT_TEST:
+    case VIR_DOMAIN_VIRT_QEMU:
+    case VIR_DOMAIN_VIRT_KQEMU:
+    case VIR_DOMAIN_VIRT_KVM:
+        if (type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
+            if (STREQ(def->os.arch, "ppc64") &&
+                STREQ(def->os.machine, "pseries")) {
+                return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
+            } else {
+                return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
+            }
+        }
+    default:
+       return -1;
+    }
+}
+
 int
 virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def)
 {
@@ -3469,6 +3491,7 @@ virDomainControllerModelTypeFromString(const virDomainControllerDefPtr def,
  */
 static virDomainControllerDefPtr
 virDomainControllerDefParseXML(xmlNodePtr node,
+                               virDomainDefPtr dom,
                                unsigned int flags)
 {
     virDomainControllerDefPtr def;
@@ -3510,6 +3533,10 @@ virDomainControllerDefParseXML(xmlNodePtr node,
         def->model = -1;
     }
 
+    if (def->model == -1 ||
+        def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO)
+        def->model = virDomainControllerDefaultModel(dom, def->type);
+
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
         goto error;
 
@@ -6562,7 +6589,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
             goto error;
     } else if (xmlStrEqual(node->name, BAD_CAST "controller")) {
         dev->type = VIR_DOMAIN_DEVICE_CONTROLLER;
-        if (!(dev->data.controller = virDomainControllerDefParseXML(node, flags)))
+        if (!(dev->data.controller = virDomainControllerDefParseXML(node, def, flags)))
             goto error;
     } else if (xmlStrEqual(node->name, BAD_CAST "graphics")) {
         dev->type = VIR_DOMAIN_DEVICE_GRAPHICS;
@@ -7124,7 +7151,7 @@ static int virDomainDefMaybeAddController(virDomainDefPtr def,
 
     cont->type = type;
     cont->idx = idx;
-    cont->model = -1;
+    cont->model = virDomainControllerDefaultModel(def, type);
 
     if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) {
         cont->opts.vioserial.ports = -1;
@@ -7693,6 +7720,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         goto no_memory;
     for (i = 0 ; i < n ; i++) {
         virDomainControllerDefPtr controller = virDomainControllerDefParseXML(nodes[i],
+                                                                              def,
                                                                               flags);
         if (!controller)
             goto error;
-- 
1.7.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]