]> xenbits.xensource.com Git - libvirt.git/commitdiff
spice: add <clipboard copypaste='yes|no'> option
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Tue, 14 Jun 2011 11:35:48 +0000 (13:35 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 14 Jun 2011 23:03:26 +0000 (17:03 -0600)
From a security pov copy and paste between the guest and the client is not
always desirable. So we need to be able to enable/disable this. The best place
to do this from an administration pov is on the hypervisor, so the qemu cmdline
is getting a spice disable-copy-paste option, see bug 693645. Example qemu
invocation:
qemu -spice port=5932,disable-ticketing,disable-copy-paste

https://bugzilla.redhat.com/show_bug.cgi?id=693661

.mailmap
docs/formatdomain.html.in
docs/schemas/domain.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms
src/qemu/qemu_command.c
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml

index 451551082b3fb4f27723b6d61deda3947b00427a..fb167ff1041aecf7dc9275f103690a10bc4bcf15 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -21,3 +21,4 @@
 <wency@cn.fujitsu.com> <wency cn fujitsu com>
 <cardoe@cardoe.com> <cardoe@gentoo.org>
 <fsimonce@redhat.com> <federico.simoncelli@gmail.com>
+<marcandre.lureau@redhat.com> <marcandre.lureau@gmail.com>
index 98fb2b4de75600a1e66dee2f7060f620e8bf3730..267839b577627060476340089967a5848e325ead 100644 (file)
@@ -1838,6 +1838,7 @@ qemu-kvm -net nic,model=? /dev/null
     &lt;channel name='record' mode='insecure'/&gt;
     &lt;image compression='auto_glz'/&gt;
     &lt;streaming mode='filter'/&gt;
+    &lt;clipboard copypaste='no'/&gt;
   &lt;/graphics&gt;</pre>
             <p>
               Spice supports variable compression settings for audio,
@@ -1862,6 +1863,14 @@ qemu-kvm -net nic,model=? /dev/null
               of <code>filter</code>, <code>all</code>
               or <code>off</code>, <span class="since">since 0.9.2</span>.
             </p>
+            <p>
+              Copy &amp; Paste functionality (via Spice agent) is set
+              by the <code>clipboard</code> element. It is enabled by
+              default, and can be disabled by setting
+              the <code>copypaste</code> property
+              to <code>no</code>, <span class="since">since
+              0.9.3</span>.
+            </>
           </dd>
           <dt><code>"rdp"</code></dt>
           <dd>
index 0be03711a4bb537a029e7180b643ef8f8a6a8f9f..b71778bda369ca0638abe856d17a7c5e27a5cb03 100644 (file)
                 <empty/>
               </element>
             </optional>
+            <optional>
+              <element name="clipboard">
+                <attribute name="copypaste">
+                  <choice>
+                    <value>yes</value>
+                    <value>no</value>
+                  </choice>
+                </attribute>
+                <empty/>
+              </element>
+            </optional>
           </interleave>
         </group>
         <group>
index be5267bf2cce827e971155b71c66fc417291d907..7393690dfbc16886f98bd04660b634d9a3fc7f31 100644 (file)
@@ -364,6 +364,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode,
               "all",
               "off");
 
+VIR_ENUM_IMPL(virDomainGraphicsSpiceClipboardCopypaste,
+              VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_LAST,
+              "default",
+              "yes",
+              "no");
+
 VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
               "subsystem",
               "capabilities")
@@ -4287,6 +4293,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
                     VIR_FREE(mode);
 
                     def->data.spice.streaming = modeVal;
+                } else if (xmlStrEqual(cur->name, BAD_CAST "clipboard")) {
+                    const char *copypaste = virXMLPropString(cur, "copypaste");
+                    int copypasteVal;
+
+                    if (!copypaste) {
+                        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+                                             _("spice clipboard missing copypaste"));
+                        goto error;
+                    }
+
+                    if ((copypasteVal =
+                         virDomainGraphicsSpiceClipboardCopypasteTypeFromString(copypaste)) <= 0) {
+                        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                             _("unknown copypaste value '%s'"), copypaste);
+                        VIR_FREE(copypaste);
+                        goto error;
+                    }
+                    VIR_FREE(copypaste);
+
+                    def->data.spice.copypaste = copypasteVal;
                 }
             }
             cur = cur->next;
@@ -9212,7 +9238,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         }
         if (!children && (def->data.spice.image || def->data.spice.jpeg ||
                           def->data.spice.zlib || def->data.spice.playback ||
-                          def->data.spice.streaming)) {
+                          def->data.spice.streaming || def->data.spice.copypaste)) {
             virBufferAddLit(buf, ">\n");
             children = 1;
         }
@@ -9231,6 +9257,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         if (def->data.spice.streaming)
             virBufferAsprintf(buf, "      <streaming mode='%s'/>\n",
                               virDomainGraphicsSpiceStreamingModeTypeToString(def->data.spice.streaming));
+        if (def->data.spice.copypaste)
+            virBufferAsprintf(buf, "      <clipboard copypaste='%s'/>\n",
+                              virDomainGraphicsSpiceClipboardCopypasteTypeToString(def->data.spice.copypaste));
     }
 
     if (children) {
index 41c8136ce8a45c4af7f1f0eb5b6352690f766d11..3ef48d14f43b797e61aeef28ba3cd1290d1412f6 100644 (file)
@@ -715,6 +715,14 @@ enum virDomainGraphicsSpiceStreamingMode {
     VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST
 };
 
+enum virDomainGraphicsSpiceClipboardCopypaste {
+    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_DEFAULT = 0,
+    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_YES,
+    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO,
+
+    VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_LAST
+};
+
 typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
 typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
 struct _virDomainGraphicsDef {
@@ -757,6 +765,7 @@ struct _virDomainGraphicsDef {
             int zlib;
             int playback;
             int streaming;
+            int copypaste;
         } spice;
     } data;
 };
@@ -1553,6 +1562,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
 VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
 VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
 VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
+VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
 /* from libvirt.h */
 VIR_ENUM_DECL(virDomainState)
 VIR_ENUM_DECL(virDomainNostateReason)
index 7a05539ce57693b2f156121b436253a11f45d05c..635193839b8219eb0787d861e9175a1591ac6eef 100644 (file)
@@ -274,8 +274,10 @@ virDomainGraphicsSpiceChannelModeTypeFromString;
 virDomainGraphicsSpiceChannelModeTypeToString;
 virDomainGraphicsSpiceChannelNameTypeFromString;
 virDomainGraphicsSpiceChannelNameTypeToString;
-virDomainGraphicsSpiceImageCompressionTypeToString;
+virDomainGraphicsSpiceClipboardCopypasteFromString;
+virDomainGraphicsSpiceClipboardCopypasteToString;
 virDomainGraphicsSpiceImageCompressionTypeFromString;
+virDomainGraphicsSpiceImageCompressionTypeToString;
 virDomainGraphicsSpiceJpegCompressionTypeFromString;
 virDomainGraphicsSpiceJpegCompressionTypeToString;
 virDomainGraphicsSpicePlaybackCompressionTypeFromString;
index cb81354f7ff14d3566651ad99a6a85f06f94b248..f3607a97c30fe95dba1aeb855c9d8dc483f88f7c 100644 (file)
@@ -4161,6 +4161,8 @@ qemuBuildCommandLine(virConnectPtr conn,
         if (def->graphics[0]->data.spice.streaming)
             virBufferAsprintf(&opt, ",streaming-video=%s",
                               virDomainGraphicsSpiceStreamingModeTypeToString(def->graphics[0]->data.spice.streaming));
+        if (def->graphics[0]->data.spice.copypaste == VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO)
+            virBufferAddLit(&opt, ",disable-copy-paste");
 
         virCommandAddArg(cmd, "-spice");
         virCommandAddArgBuffer(cmd, &opt);
index 084a10019784fcd2ef615f5bc7e169d96ae46715..c9fdb99276bded38eb4ea43b3052ee9e1a96aeaf 100644 (file)
@@ -4,6 +4,6 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
 /dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs,\
 image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
-playback-compression=on,streaming-video=filter -vga \
+playback-compression=on,streaming-video=filter,disable-copy-paste -vga \
 qxl -global qxl.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 0d3dd48761d8c134545b1dbab7c0a56db8fdb4f1..79780c63491bc7e4ca8fe18b0fe206a5a17d0ebe 100644 (file)
@@ -29,6 +29,7 @@
       <zlib compression='auto'/>
       <playback compression='on'/>
       <streaming mode='filter'/>
+      <clipboard copypaste='no'/>
     </graphics>
     <video>
       <model type='qxl' vram='18432' heads='1'/>