[libvirt] [PATCH V2 3/6] qemu: Add support for secondary-vga

Wang Rui moon.wangrui at huawei.com
Mon Jul 14 11:20:45 UTC 2014


From: Zeng Junliang <zengjunliang at huawei.com>

Secondary-vga is supported by QEMU in currently master.
Add it supported in libvirt as qemu commandline shows:
'-device secondary-vga'.

Signed-off-by: Zeng Junliang <zengjunliang at huawei.com>
Signed-off-by: Wang Rui <moon.wangrui at huawei.com>
---
 src/conf/domain_conf.c       | 16 ++++++++------
 src/conf/domain_conf.h       |  1 +
 src/qemu/qemu_capabilities.c |  2 ++
 src/qemu/qemu_capabilities.h |  1 +
 src/qemu/qemu_command.c      | 50 ++++++++++++++++++++++++++++++--------------
 5 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d5a65c3..216d4e1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -478,7 +478,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
               "vmvga",
               "xen",
               "vbox",
-              "qxl")
+              "qxl",
+              "secondary")
 
 VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST,
               "mouse",
@@ -9335,7 +9336,8 @@ virDomainVideoDefaultVgamem(int type)
     case VIR_DOMAIN_VIDEO_TYPE_VGA:
     case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
     case VIR_DOMAIN_VIDEO_TYPE_QXL:
-        /* QEMU use 16M as default value for vga/vmvga/qxl device*/
+    case VIR_DOMAIN_VIDEO_TYPE_SECONDARY:
+        /* QEMU use 16M as default value for vga/vmvga/qxl/secondary device*/
         return 16 * 1024;
 
     default:
@@ -9491,10 +9493,11 @@ virDomainVideoDefParseXML(xmlNodePtr node,
          * for VIR_DOMAIN_VIDEO_TYPE_VMVGA. Shall we also need
          * to add judge here? Will it affect other drivers? */
         if (def->type == VIR_DOMAIN_VIDEO_TYPE_VGA ||
-            def->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS) {
+            def->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS ||
+            def->type == VIR_DOMAIN_VIDEO_TYPE_SECONDARY) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("vram attribute is not supported "
-                             "for type of vga and cirrus"));
+                             "for type of vga, cirrus, qxl and secondary"));
             goto error;
         }
         if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) {
@@ -9509,10 +9512,11 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     if (vgamem) {
         if (def->type != VIR_DOMAIN_VIDEO_TYPE_VGA &&
             def->type != VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
-            def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            def->type != VIR_DOMAIN_VIDEO_TYPE_QXL &&
+            def->type != VIR_DOMAIN_VIDEO_TYPE_SECONDARY) {
             virReportError(VIR_ERR_XML_ERROR, "%s",
                            _("vgamem attribute only supported "
-                             "for type of vga, vmvga and qxl"));
+                             "for type of vga, vmvga, qxl and secondary"));
             goto error;
         }      
         if (virStrToLong_ui(vgamem, NULL, 10, &def->vgamem) < 0) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a63ec84..bf1bd55 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1199,6 +1199,7 @@ typedef enum {
     VIR_DOMAIN_VIDEO_TYPE_XEN,
     VIR_DOMAIN_VIDEO_TYPE_VBOX,
     VIR_DOMAIN_VIDEO_TYPE_QXL,
+    VIR_DOMAIN_VIDEO_TYPE_SECONDARY,
 
     VIR_DOMAIN_VIDEO_TYPE_LAST
 } virDomainVideoType;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c665e2b..68b86dc 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -259,6 +259,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "msg-timestamp",
               "active-commit",
               "change-backing-file",
+              "secondary-vga",
     );
 
 
@@ -1451,6 +1452,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "spicevmc", QEMU_CAPS_DEVICE_SPICEVMC },
     { "qxl-vga", QEMU_CAPS_DEVICE_QXL_VGA },
     { "qxl", QEMU_CAPS_DEVICE_QXL },
+    { "secondary-vga", QEMU_CAPS_DEVICE_SECONDARY_VGA },
     { "sga", QEMU_CAPS_SGA },
     { "scsi-block", QEMU_CAPS_SCSI_BLOCK },
     { "scsi-cd", QEMU_CAPS_SCSI_CD },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 99cf9ed..73c45d7 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -209,6 +209,7 @@ typedef enum {
     QEMU_CAPS_MSG_TIMESTAMP      = 167, /* -msg timestamp */
     QEMU_CAPS_ACTIVE_COMMIT      = 168, /* block-commit works without 'top' */
     QEMU_CAPS_CHANGE_BACKING_FILE = 169, /* change name of backing file in metadata */
+    QEMU_CAPS_DEVICE_SECONDARY_VGA = 170, /* -device secondary-vga */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cb6d6e2..3a6762c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -109,7 +109,9 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
               "vmware",
               "", /* no arg needed for xen */
               "", /* don't support vbox */
-              "qxl");
+              "qxl",
+              ""); /* '-vga XXX' for secondary-vga device
+                    * is currently not supported with QEMU */
 
 VIR_ENUM_DECL(qemuDeviceVideo)
 
@@ -119,7 +121,8 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
               "vmware-svga",
               "", /* no device for xen */
               "", /* don't support vbox */
-              "qxl-vga");
+              "qxl-vga",
+              "secondary-vga");
 
 VIR_ENUM_DECL(qemuSoundCodec)
 
@@ -2256,9 +2259,11 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
     }
     /* Further non-primary video cards which have to be qxl type */
     for (i = 1; i < def->nvideos; i++) {
-        if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+        if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL
+            && def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_SECONDARY) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("non-primary video device must be type of 'qxl'"));
+                           _("non-primary video device must be "
+                             "type of 'qxl' or 'secondary'"));
             goto error;
         }
         if (def->videos[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
@@ -4774,19 +4779,29 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
             goto error;
         }
     } else {
-        if (video->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           "%s", _("non-primary video device must be type of 'qxl'"));
-            goto error;
-        }
-
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) {
+        switch (video->type) {
+        case VIR_DOMAIN_VIDEO_TYPE_QXL:
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               "%s", _("only one video card is currently supported"));
+                goto error;
+            }
+            model = "qxl";
+            break;
+        case VIR_DOMAIN_VIDEO_TYPE_SECONDARY:
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SECONDARY_VGA)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               "%s", _("only one video card is currently supported"));
+                goto error;
+            }
+            model = "secondary-vga";
+            break;
+        default:
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           "%s", _("only one video card is currently supported"));
+                           "%s", _("non-primary video device must be "
+                           "type of 'qxl' or 'secondary'"));
             goto error;
         }
-
-        model = "qxl";
     }
 
     virBufferAsprintf(&buf, "%s,id=%s", model, video->info.alias);
@@ -8474,7 +8489,9 @@ qemuBuildCommandLine(virConnectPtr conn,
              (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
                  virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) ||
              (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL &&
-                 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)))
+                 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)) ||
+             (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_SECONDARY &&
+                 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SECONDARY_VGA)))
            ) {
             for (i = 0; i < def->nvideos; i++) {
                 char *str;
@@ -8563,7 +8580,8 @@ qemuBuildCommandLine(virConnectPtr conn,
                 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
                     for (i = 1; i < def->nvideos; i++) {
                         char *str;
-                        if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+                        if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL
+                            && def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_SECONDARY) {
                             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                            _("video type %s is only valid as primary video card"),
                                            virDomainVideoTypeToString(def->videos[0]->type));
-- 
1.7.12.4





More information about the libvir-list mailing list