render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From f7b5000e807b3907165edd784fcf59a682d1d5ad Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <f7b5000e807b3907165edd784fcf59a682d1d5ad@dist-git>
7a3408
From: John Ferlan <jferlan@redhat.com>
7a3408
Date: Fri, 4 Sep 2015 08:55:45 -0400
7a3408
Subject: [PATCH] qemu: Introduce qemuDomainMachineIsS390CCW
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1258361
7a3408
7a3408
Rather than have different usages of STR function in order to determine
7a3408
whether the domain is s390-ccw or s390-ccw-virtio, make a single API
7a3408
which will check the machine.os prefix. Then use the function.
7a3408
7a3408
(cherry picked from commit d334c91751c8eea33abe8e92761433a145e38112)
7a3408
Signed-off-by: John Ferlan <jferlan@redhat.com>
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_command.c |  4 ++--
7a3408
 src/qemu/qemu_domain.c  |  6 ++++++
7a3408
 src/qemu/qemu_domain.h  |  1 +
7a3408
 src/qemu/qemu_hotplug.c | 12 ++++++------
7a3408
 4 files changed, 15 insertions(+), 8 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
7a3408
index f3e45a5..f8fb71e 100644
7a3408
--- a/src/qemu/qemu_command.c
7a3408
+++ b/src/qemu/qemu_command.c
7a3408
@@ -1327,7 +1327,7 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
7a3408
     virDomainCCWAddressSetPtr addrs = NULL;
7a3408
     qemuDomainObjPrivatePtr priv = NULL;
7a3408
 
7a3408
-    if (STREQLEN(def->os.machine, "s390-ccw", 8) &&
7a3408
+    if (qemuDomainMachineIsS390CCW(def) &&
7a3408
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
7a3408
         qemuDomainPrimeVirtioDeviceAddresses(
7a3408
             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
7a3408
@@ -1826,7 +1826,7 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm,
7a3408
         devstr = info->alias;
7a3408
 
7a3408
     if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
7a3408
-        STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
7a3408
+        qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW) &&
7a3408
         virDomainCCWAddressReleaseAddr(priv->ccwaddrs, info) < 0)
7a3408
         VIR_WARN("Unable to release CCW address on %s",
7a3408
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
7a3408
index 943d727..66d8e3a 100644
7a3408
--- a/src/qemu/qemu_domain.c
7a3408
+++ b/src/qemu/qemu_domain.c
7a3408
@@ -3294,6 +3294,12 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def)
7a3408
 }
7a3408
 
7a3408
 
7a3408
+bool
7a3408
+qemuDomainMachineIsS390CCW(const virDomainDef *def)
7a3408
+{
7a3408
+    return STRPREFIX(def->os.machine, "s390-ccw");
7a3408
+}
7a3408
+
7a3408
 
7a3408
 /**
7a3408
  * qemuDomainUpdateCurrentMemorySize:
7a3408
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
7a3408
index 2af7c59..91eaea1 100644
7a3408
--- a/src/qemu/qemu_domain.h
7a3408
+++ b/src/qemu/qemu_domain.h
7a3408
@@ -469,6 +469,7 @@ virDomainChrSourceDefPtr qemuFindAgentConfig(virDomainDefPtr def);
7a3408
 bool qemuDomainMachineIsQ35(const virDomainDef *def);
7a3408
 bool qemuDomainMachineIsI440FX(const virDomainDef *def);
7a3408
 bool qemuDomainMachineNeedsFDC(const virDomainDef *def);
7a3408
+bool qemuDomainMachineIsS390CCW(const virDomainDef *def);
7a3408
 
7a3408
 int qemuDomainUpdateCurrentMemorySize(virQEMUDriverPtr driver,
7a3408
                                       virDomainObjPtr vm);
7a3408
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
7a3408
index aabdb78..b79fc56 100644
7a3408
--- a/src/qemu/qemu_hotplug.c
7a3408
+++ b/src/qemu/qemu_hotplug.c
7a3408
@@ -326,7 +326,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
7a3408
     const char *src = virDomainDiskGetSource(disk);
7a3408
 
7a3408
     if (!disk->info.type) {
7a3408
-        if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
7a3408
+        if (qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
7a3408
             disk->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
7a3408
         else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
7a3408
@@ -443,7 +443,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
7a3408
 
7a3408
     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
7a3408
         if (controller->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
7a3408
-            if (STRPREFIX(vm->def->os.machine, "s390-ccw") &&
7a3408
+            if (qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
                 virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW))
7a3408
                 controller->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
7a3408
             else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390))
7a3408
@@ -991,7 +991,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
7a3408
             goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
7a3408
+    if (qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
7a3408
         net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
7a3408
         if (virDomainCCWAddressAssign(&net->info, priv->ccwaddrs,
7a3408
@@ -1657,7 +1657,7 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
7a3408
         return -1;
7a3408
 
7a3408
     if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
7a3408
-        if (STRPREFIX(vm->def->os.machine, "s390-ccw") &&
7a3408
+        if (qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
             virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
7a3408
             rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
7a3408
         } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
7a3408
@@ -3415,7 +3415,7 @@ qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
7a3408
         goto cleanup;
7a3408
     }
7a3408
 
7a3408
-    if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
7a3408
+    if (qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
7a3408
         if (!virDomainDeviceAddressIsValid(&detach->info,
7a3408
                                            VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
7a3408
@@ -3945,7 +3945,7 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
7a3408
                                              virDomainNetGetActualHostdev(detach));
7a3408
         goto cleanup;
7a3408
     }
7a3408
-    if (STREQLEN(vm->def->os.machine, "s390-ccw", 8) &&
7a3408
+    if (qemuDomainMachineIsS390CCW(vm->def) &&
7a3408
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_CCW)) {
7a3408
         if (!virDomainDeviceAddressIsValid(&detach->info,
7a3408
                                            VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
7a3408
-- 
7a3408
2.5.1
7a3408