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

[libvirt] [PATCH 2/2] Modify interface qemuDefaultScsiControllerModel().



Now, the libvirt sets the default module as 'ibmvscsi'
for pseries, and 'lsi' for other platforms.The controller
model should be set according to controller type, not
only just the platform, otherwise, it will have to set 
controller's model externally to select right model 
for specific controller type. 

This patch is to modify the qemuDefaultScsiControllerModel()
interface to set right controller model according to the 
controller's type.

For pseries guest, PCI scsi controller is also supported.
So the default scsi controller model is set according to
the contrller type. If it is PCI scsi controller, the 
default model is set as lsi, and if it is VSCSI controller, 
the default model is set as ibmvscsi.

Signed-off-by: Li Zhang <zhlcindy linux vnet ibm com>
---
 src/conf/domain_conf.c  |    4 ++--
 src/qemu/qemu_command.c |   51 +++++++++++++++++++++++++++++++----------------
 src/qemu/qemu_command.h |    3 +--
 src/qemu/qemu_hotplug.c |    2 +-
 4 files changed, 38 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 99005b7..44130c7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4097,7 +4097,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
         def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
         def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                             _("Controllers must use the 'pci' address type"));
+                             _("Controllers must use the 'pci' or 'spapr-vio' address type"));
         goto error;
     }
 
@@ -4549,7 +4549,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
         def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO &&
         def->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
         virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                             _("Network interfaces must use 'pci' address type"));
+                             _("Network interfaces must use 'pci' or 'spapr-vio' address type"));
         goto error;
     }
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bb3be17..d31dae2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -463,9 +463,8 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk)
 }
 
 static int
-qemuDefaultScsiControllerModel(virDomainDefPtr def) {
-    if (STREQ(def->os.arch, "ppc64") &&
-        STREQ(def->os.machine, "pseries")) {
+qemuDefaultScsiControllerModel(int ctlType) {
+    if (ctlType == VIR_DOMAIN_CONTROLLER_TYPE_VSCSI) {
         return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI;
     } else {
         return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC;
@@ -479,19 +478,30 @@ qemuAssignDeviceDiskAliasCustom(virDomainDefPtr def,
 {
     const char *prefix = virDomainDiskBusTypeToString(disk->bus);
     int controllerModel = -1;
+    int controllerType = -1;
 
     if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) {
         if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
-            controllerModel =
-                virDomainDiskFindControllerModel(def, disk,
-                                                 VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
+            controllerType = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
+        } else if (disk->bus == VIR_DOMAIN_DISK_BUS_VSCSI) {
+            controllerType = VIR_DOMAIN_CONTROLLER_TYPE_VSCSI;
+        } else {
+            qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                        _("Unsupported disk bus type '%s'"),
+                        virDomainDiskBusTypeToString(disk->bus));
+            return -1;
         }
 
+        controllerModel =
+            virDomainDiskFindControllerModel(def, disk,
+                                             controllerType);
+
         if (controllerModel == -1 ||
             controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO)
-            controllerModel = qemuDefaultScsiControllerModel(def);
+            controllerModel = qemuDefaultScsiControllerModel(controllerType);
 
-        if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI ||
+        if ((disk->bus != VIR_DOMAIN_DISK_BUS_SCSI &&
+             disk->bus != VIR_DOMAIN_DISK_BUS_VSCSI) ||
             controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
             if (virAsprintf(&disk->info.alias, "%s%d-%d-%d", prefix,
                             disk->info.addr.drive.controller,
@@ -2173,6 +2183,7 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
     const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
     int idx = virDiskNameToIndex(disk->dst);
     int controllerModel;
+    int controllerType;
 
     if (idx < 0) {
         qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2236,12 +2247,18 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
             }
         }
 
-        controllerModel =
-            virDomainDiskFindControllerModel(def, disk,
-                                             VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
+        if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)
+            controllerType = VIR_DOMAIN_CONTROLLER_TYPE_SCSI;
+        else
+            controllerType = VIR_DOMAIN_CONTROLLER_TYPE_VSCSI;
+
+         controllerModel =
+                virDomainDiskFindControllerModel(def, disk,
+                                             controllerType);
+
         if (controllerModel == -1 ||
             controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO)
-            controllerModel = qemuDefaultScsiControllerModel(def);
+            controllerModel = qemuDefaultScsiControllerModel(controllerType);
 
         if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
             if (disk->info.addr.drive.target != 0) {
@@ -2547,8 +2564,7 @@ qemuBuildUSBControllerDevStr(virDomainControllerDefPtr def,
 }
 
 char *
-qemuBuildControllerDevStr(virDomainDefPtr domainDef,
-                          virDomainControllerDefPtr def,
+qemuBuildControllerDevStr(virDomainControllerDefPtr def,
                           virBitmapPtr qemuCaps,
                           int *nusbcontroller)
 {
@@ -2557,10 +2573,11 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
 
     switch (def->type) {
     case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+    case VIR_DOMAIN_CONTROLLER_TYPE_VSCSI:
         model = def->model;
         if (model == -1 ||
             model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO) {
-            model = qemuDefaultScsiControllerModel(domainDef);
+            model = qemuDefaultScsiControllerModel(def->type);
         }
         switch (model) {
         case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI:
@@ -4551,7 +4568,7 @@ qemuBuildCommandLine(virConnectPtr conn,
                     char *devstr;
 
                     virCommandAddArg(cmd, "-device");
-                    if (!(devstr = qemuBuildControllerDevStr(def, cont, qemuCaps, NULL)))
+                    if (!(devstr = qemuBuildControllerDevStr(cont, qemuCaps, NULL)))
                         goto error;
 
                     virCommandAddArg(cmd, devstr);
@@ -4570,7 +4587,7 @@ qemuBuildCommandLine(virConnectPtr conn,
                 virCommandAddArg(cmd, "-device");
 
                 char *devstr;
-                if (!(devstr = qemuBuildControllerDevStr(def, def->controllers[i], qemuCaps,
+                if (!(devstr = qemuBuildControllerDevStr(def->controllers[i], qemuCaps,
                                                          &usbcontroller)))
                     goto error;
 
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 1eafeb3..13d9cb8 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -97,8 +97,7 @@ char * qemuBuildDriveDevStr(virDomainDefPtr def,
 char * qemuBuildFSDevStr(virDomainFSDefPtr fs,
                          virBitmapPtr qemuCaps);
 /* Current, best practice */
-char * qemuBuildControllerDevStr(virDomainDefPtr domainDef,
-                                 virDomainControllerDefPtr def,
+char * qemuBuildControllerDevStr(virDomainControllerDefPtr def,
                                  virBitmapPtr qemuCaps,
                                  int *nusbcontroller);
 
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7cf7b90..5b1dee2 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -340,7 +340,7 @@ int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver,
             goto cleanup;
         }
 
-        if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL))) {
+        if (!(devstr = qemuBuildControllerDevStr(controller, priv->qemuCaps, NULL))) {
             goto cleanup;
         }
     }
-- 
1.7.9.5


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