[libvirt] [PATCHv5 7/9] RFC: spicevmc: call out vdagent as a channel target

Eric Blake eblake at redhat.com
Fri Feb 4 04:16:09 UTC 2011


Not sure this makes sense to do; posting it for comments,
but I'm okay with ditching the idea (especially since
existing RHEL 6.0 guests have already been using XML that
targets virtio, which means changing to vdagent would
cause the need for a naming transition).

* docs/schemas/domain.rng: Tweak the spicevmc XML.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (virDomainChrChannelTargetType):
New enum value.
* src/conf/domain_conf.c (virDomainChrChannelTarget):
Add vdagent.
(virDomainChrDefParseXML, virDomainChrSourceDefParseXML)
(virDomainChrDefParseTargetXML): Parse and enforce proper use.
(virDomainChrSourceDefFormat, virDomainChrDefFormat): Format.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildCommandLine): Add qemu support.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml: Tweak.
---
 docs/formatdomain.html.in                          |   12 +++++-----
 docs/schemas/domain.rng                            |   13 ++++++++++++
 src/conf/domain_conf.c                             |   20 ++++++++++++++++--
 src/conf/domain_conf.h                             |    1 +
 src/qemu/qemu_command.c                            |   21 ++++++++++++++++++++
 .../qemuxml2argv-channel-spicevmc.args             |    4 +-
 .../qemuxml2argv-channel-spicevmc.xml              |    2 +-
 7 files changed, 61 insertions(+), 12 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index d91fdb9..a9d2f84 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1735,7 +1735,7 @@ qemu-kvm -net nic,model=? /dev/null
       <target type='virtio' name='arbitrary.virtio.serial.port.name'/>
     </channel>
     <channel type='spicevmc'>
-      <target type='virtio' name='com.redhat.spice.0'/>
+      <target type='vdagent' name='com.redhat.spice.0'/>
     </channel>
   </devices>
   ...</pre>
@@ -1767,11 +1767,11 @@ qemu-kvm -net nic,model=? /dev/null
       <dd>Paravirtualized SPICE channel. The domain must also have a
         SPICE server as a <a href="#elementsGraphics">graphics
         device</a>, at which point the host piggy-backs messages
-        across the <code>main</code> channel.  The <code>target</code>
-        element must be present, with
-        attribute <code>type='virtio'</code>; an optional
-        attribute <code>name</code> controls how the guest will have
-        access to the channel, and defaults
+        across the <code>main</code> channel.  For now, the only
+        supported channel is vdagent, so the <code>target</code>
+        element must have attribute <code>type='vdagent'</code>; an
+        optional attribute <code>name</code> controls how the guest
+        will have access to the channel, and defaults
         to <code>name='com.redhat.spice.0'</code>.  The
         optional <code>address</code> element can tie the channel to a
         particular <code>type='virtio-serial'</code> controller.
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 9ffcf21..40f33e8 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1619,6 +1619,18 @@
       </optional>
     </element>
   </define>
+  <define name="vdagentTarget">
+    <element name="target">
+      <attribute name="type">
+        <value>vdagent</value>
+      </attribute>
+      <optional>
+        <attribute name="name">
+          <value>com.redhat.spice.0</value>
+        </attribute>
+      </optional>
+    </element>
+  </define>
   <define name="channel">
     <element name="channel">
       <ref name="qemucdevSrcType"/>
@@ -1627,6 +1639,7 @@
         <choice>
           <ref name="guestfwdTarget"/>
           <ref name="virtioTarget"/>
+          <ref name="vdagentTarget"/>
         </choice>
         <optional>
           <ref name="address"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9b4ef8d..3d7d63e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -201,7 +201,8 @@ VIR_ENUM_IMPL(virDomainNetBackend, VIR_DOMAIN_NET_BACKEND_TYPE_LAST,
 VIR_ENUM_IMPL(virDomainChrChannelTarget,
               VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
               "guestfwd",
-              "virtio")
+              "virtio",
+              "vdagent")

 VIR_ENUM_IMPL(virDomainChrConsoleTarget,
               VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST,
@@ -2944,6 +2945,16 @@ virDomainChrDefParseTargetXML(virCapsPtr caps,
         case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
             def->target.name = virXMLPropString(cur, "name");
             break;
+
+        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VDAGENT:
+            if (def->source.type != VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
+                virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+                                     _("vdagent only valid with spicevmc "
+                                       "channel"));
+                goto error;
+            }
+
+            break;
         }
         break;

@@ -3257,9 +3268,9 @@ virDomainChrDefParseXML(virCapsPtr caps,
     }

     if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC &&
-        def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
+        def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VDAGENT) {
         virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                             _("spicevmc device type only supports virtio"));
+                             _("spicevmc device type only supports vdagent"));
         goto error;
     }

@@ -6993,6 +7004,9 @@ virDomainChrDefFormat(virBufferPtr buf,
             break;
         }

+        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VDAGENT:
+            break;
+
         }
         virBufferAddLit(buf, "/>\n");
         break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9dff580..0728dc3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -389,6 +389,7 @@ enum virDomainChrDeviceType {
 enum virDomainChrChannelTargetType {
     VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD = 0,
     VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
+    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VDAGENT,

     VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1903c70..ba60d0a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3694,6 +3694,27 @@ qemuBuildCommandLine(virConnectPtr conn,
             virCommandAddArg(cmd, devstr);
             VIR_FREE(devstr);
             break;
+
+        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VDAGENT:
+            if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                    _("virtio channel requires QEMU to support -device"));
+                goto error;
+            }
+            virCommandAddArg(cmd, "-chardev");
+            if (!(devstr = qemuBuildChrChardevStr(&channel->source,
+                                                  channel->info.alias,
+                                                  qemuCmdFlags)))
+                goto error;
+            virCommandAddArg(cmd, devstr);
+            VIR_FREE(devstr);
+
+            virCommandAddArg(cmd, "-device");
+            if (!(devstr = qemuBuildVirtioSerialPortDevStr(channel)))
+                goto error;
+            virCommandAddArg(cmd, devstr);
+            VIR_FREE(devstr);
+            break;
         }
     }

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
index 681f7c2..3e1eaed 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
@@ -3,7 +3,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
 virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda \
 /dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent -device \
-virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0\
-,name=com.redhat.spice.0 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
+virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0 \
+-usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=main -device \
 virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
index 0e82394..b99f3ce 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
@@ -26,7 +26,7 @@
       <channel name='main' mode='secure'/>
     </graphics>
     <channel type='spicevmc'>
-      <target type='virtio' name='com.redhat.spice.0'/>
+      <target type='vdagent'/>
       <address type='virtio-serial' controller='1' bus='0' port='3'/>
     </channel>
     <memballoon model='virtio'/>
-- 
1.7.4




More information about the libvir-list mailing list