diff mbox

[05/17] qemu: Drop some simple uses of QEMU_CAPS_DEVICE

Message ID 68be92f5c86549d2f105a2795e013b243474d6f0.1453489952.git.crobinso@redhat.com
State New
Headers show

Commit Message

Cole Robinson Jan. 22, 2016, 7:30 p.m. UTC
---
 src/qemu/qemu_command.c | 82 +++++++++----------------------------------------
 1 file changed, 15 insertions(+), 67 deletions(-)

-- 
2.5.0

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

Patch

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dade9f5..594cee6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -471,12 +471,9 @@  qemuNetworkIfaceConnect(virDomainDefPtr def,
 
 static bool
 qemuDomainSupportsNicdev(virDomainDefPtr def,
-                         virQEMUCapsPtr qemuCaps,
+                         virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
                          virDomainNetDefPtr net)
 {
-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
-        return false;
-
     /* non-virtio ARM nics require legacy -net nic */
     if (((def->os.arch == VIR_ARCH_ARMV7L) ||
         (def->os.arch == VIR_ARCH_AARCH64)) &&
@@ -1185,9 +1182,6 @@  qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
         }
     }
 
-    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
-        return 0;
-
     for (i = 0; i < def->nfss; i++) {
         if (virAsprintf(&def->fss[i]->info.alias, "fs%zu", i) < 0)
             return -1;
@@ -1873,7 +1867,6 @@  qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
         VIR_WARN("Unable to release CCW address on %s",
                  NULLSTR(devstr));
     else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
-             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
              virDomainPCIAddressReleaseSlot(priv->pciaddrs,
                                             &info->addr.pci) < 0)
         VIR_WARN("Unable to release PCI address on %s",
@@ -3734,9 +3727,7 @@  qemuBuildDriveStr(virConnectPtr conn,
     int busid = -1, unitid = -1;
     char *source = NULL;
     int actualType = virStorageSourceGetActualType(disk->src);
-    bool usesDeviceArg = (
-        virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
-        (disk->bus != VIR_DOMAIN_DISK_BUS_SD));
+    bool usesDeviceArg = (disk->bus != VIR_DOMAIN_DISK_BUS_SD);
 
     if (idx < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -9632,22 +9623,15 @@  qemuBuildCommandLine(virConnectPtr conn,
             virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
     }
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-        /* Disable global config files and default devices */
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_USER_CONFIG))
-            virCommandAddArg(cmd, "-no-user-config");
-        else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NODEFCONFIG))
-            virCommandAddArg(cmd, "-nodefconfig");
-        virCommandAddArg(cmd, "-nodefaults");
-    }
+    /* Disable global config files and default devices */
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_USER_CONFIG))
+        virCommandAddArg(cmd, "-no-user-config");
+    else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NODEFCONFIG))
+        virCommandAddArg(cmd, "-nodefconfig");
+    virCommandAddArg(cmd, "-nodefaults");
 
     /* Serial graphics adapter */
     if (def->os.bios.useserial == VIR_TRISTATE_BOOL_YES) {
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("qemu does not support -device"));
-            goto error;
-        }
         if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SGA)) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("qemu does not support SGA"));
@@ -10233,10 +10217,8 @@  qemuBuildCommandLine(virConnectPtr conn,
         /* Unfortunately it is not possible to use -device for SD devices.
            Fortunately, those don't need static PCI addresses, so we don't
            really care that we can't use -device */
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-            if (disk->bus != VIR_DOMAIN_DISK_BUS_SD)
-                withDeviceArg = true;
-        }
+        if (disk->bus != VIR_DOMAIN_DISK_BUS_SD)
+            withDeviceArg = true;
         optstr = qemuBuildDriveStr(conn, disk,
                                    emitBootindex ? false : !!bootindex,
                                    qemuCaps);
@@ -10519,8 +10501,7 @@  qemuBuildCommandLine(virConnectPtr conn,
             char *devstr;
 
             /* Use -chardev with -device if they are available */
-            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) &&
-                virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) {
                 virCommandAddArg(cmd, "-chardev");
                 if (!(devstr = qemuBuildChrChardevStr(&parallel->source,
                                                       parallel->info.alias,
@@ -10547,8 +10528,7 @@  qemuBuildCommandLine(virConnectPtr conn,
 
         switch (channel->targetType) {
         case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) ||
-                !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                "%s", _("guestfwd requires QEMU to support -chardev & -device"));
                 goto error;
@@ -10569,12 +10549,6 @@  qemuBuildCommandLine(virConnectPtr conn,
             break;
 
         case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("virtio channel requires QEMU to support -device"));
-                goto error;
-            }
-
             /*
              * TODO: Refactor so that we generate this (and onther
              * things) somewhere else then where we are building the
@@ -10622,11 +10596,6 @@  qemuBuildCommandLine(virConnectPtr conn,
         switch (console->targetType) {
         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("sclp console requires QEMU to support -device"));
-                goto error;
-            }
             if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCLP_S390)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("sclp console requires QEMU to support s390-sclp"));
@@ -10646,12 +10615,6 @@  qemuBuildCommandLine(virConnectPtr conn,
             break;
 
         case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO:
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("virtio channel requires QEMU to support -device"));
-                goto error;
-            }
-
             virCommandAddArg(cmd, "-chardev");
             if (!(devstr = qemuBuildChrChardevStr(&console->source,
                                                   console->info.alias,
@@ -10782,8 +10745,7 @@  qemuBuildCommandLine(virConnectPtr conn,
             const char *dev = qemuDeviceVideoTypeToString(primaryVideoType);
 
             if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
-                (def->videos[0]->vram || def->videos[0]->ram) &&
-                virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
+                (def->videos[0]->vram || def->videos[0]->ram)) {
                 unsigned int ram = def->videos[0]->ram;
                 unsigned int vram = def->videos[0]->vram;
                 unsigned int vgamem = def->videos[0]->vgamem;
@@ -10819,8 +10781,7 @@  qemuBuildCommandLine(virConnectPtr conn,
                 }
             }
 
-            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
-                def->videos[0]->vram &&
+            if (def->videos[0]->vram &&
                 ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
                   virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
                  (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
@@ -10866,11 +10827,6 @@  qemuBuildCommandLine(virConnectPtr conn,
             }
         }
 
-    } else {
-        /* If we have -device, then we set -nodefault already */
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
-            virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_NONE))
-            virCommandAddArgList(cmd, "-vga", "none", NULL);
     }
 
     /* Add sound hardware */
@@ -11009,13 +10965,6 @@  qemuBuildCommandLine(virConnectPtr conn,
         virCommandAddArg(cmd, devstr);
         VIR_FREE(devstr);
 
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("redirected devices are not supported by this QEMU"));
-            goto error;
-        }
-
-
         virCommandAddArg(cmd, "-device");
         if (!(devstr = qemuBuildRedirdevDevStr(def, redirdev, qemuCaps)))
             goto error;
@@ -11156,8 +11105,7 @@  qemuBuildCommandLine(virConnectPtr conn,
         /* SCSI */
         if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
             hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
-            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
-                virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
+            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
                 char *drvstr;
 
                 virCommandAddArg(cmd, "-drive");