From nobody Tue Feb 10 17:31:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1636109613; cv=none; d=zohomail.com; s=zohoarc; b=cfqUuaqBeeYWX0T0yTBefG7eVfEALTj4rGQRkSm5r7/vqaX8CfwSsN8/6Pp9H6BYBpnBO38XE7RdQ6bBUqcQWTNNblxLVETohsVlxuUa+EvgVBImJkrPT9ZUCKhg7hG9Q4UpVrVsQmcwTHq1qmooa1mSgBwwO0ZJc8qJ001YlfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636109613; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hzutoE9okoW3J/TnCOGfZXpQCTKnSTTLhXVYs2K4Avs=; b=UfEpCrzUKzoBP5QkiW9xaWW9DhArlC7BvqnSaSDJl/HLYYCjKftc4WrtcBettQQlX0Ou8eZSBCYLZvlUEAFLDepflnB2uxt8y2y8FT0L/de9j9LcUACHnty4iPUGE0rheytVsPx4Jf+DCM0F8n6/tdepFl8HJ6tiM4+qixg+584= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1636109613876154.0416595817211; Fri, 5 Nov 2021 03:53:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-SDCrc-xgPk64WJH0rBccow-1; Fri, 05 Nov 2021 06:53:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 951F287D549; Fri, 5 Nov 2021 10:53:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C2D85D740; Fri, 5 Nov 2021 10:53:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4181F181A1D1; Fri, 5 Nov 2021 10:53:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A5ArM3h001950 for ; Fri, 5 Nov 2021 06:53:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id C31E75D740; Fri, 5 Nov 2021 10:53:22 +0000 (UTC) Received: from localhost (unknown [10.39.208.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AE835D6B1; Fri, 5 Nov 2021 10:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636109612; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hzutoE9okoW3J/TnCOGfZXpQCTKnSTTLhXVYs2K4Avs=; b=LoKMGl0b9gB/pWxGsdEWNI+dEJLaWcsz3FRmzshie60rZvmtoviiICEBS5vmpa/KhYK0r1 gKVX8ouleoDuODx6/Rm3O+mPOO6oy9efQJoLjEnN1mauGJxvRNtp4COMFyPWAMafSWTWS1 +KvVr/aDKy2wJ4CgQmnRJgvkHl/p7ts= X-MC-Unique: SDCrc-xgPk64WJH0rBccow-1 From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] qemu: add dbus clipboard sharing Date: Fri, 5 Nov 2021 14:51:16 +0400 Message-Id: <20211105105119.117552-7-marcandre.lureau@redhat.com> In-Reply-To: <20211105105119.117552-1-marcandre.lureau@redhat.com> References: <20211105105119.117552-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1636109615565100001 From: Marc-Andr=C3=A9 Lureau This feature requires to setup a "-chardev qemu-vdagent,clipboard=3Don". "qemu-vdagent" is not a typical chardev that you can connect to another end, so it doesn't map to a or . Set it up along with "-display dbus" code instead. Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/schemas/domaincommon.rng | 8 +++++ src/conf/domain_conf.c | 7 ++++ src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 12 +++++++ .../graphics-dbus-clipboard.args | 32 +++++++++++++++++ .../graphics-dbus-clipboard.xml | 36 +++++++++++++++++++ tests/qemuxml2argvtest.c | 4 +++ 7 files changed, 100 insertions(+) create mode 100644 tests/qemuxml2argvdata/graphics-dbus-clipboard.args create mode 100644 tests/qemuxml2argvdata/graphics-dbus-clipboard.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index fcd14162bc9a..a8777acf9ea8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4034,6 +4034,14 @@ + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 82f5e44951d5..e249781ce027 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -12940,6 +12940,13 @@ virDomainGraphicsDefParseXMLDBus(virDomainGraphics= Def *def, return -1; } =20 + if ((cur =3D virXPathNode("./clipboard", ctxt))) { + if (virXMLPropTristateBool(cur, "copypaste", + VIR_XML_PROP_REQUIRED, + &def->data.dbus.copypaste) < 0) + return -1; + } + return 0; } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 6eec4230fab5..cc81dbd4a9db 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1924,6 +1924,7 @@ struct _virDomainGraphicsDef { char *rendernode; virTristateBool gl; unsigned int audioId; + virTristateBool copypaste; } dbus; } data; /* nListens, listens, and *port are only useful if type is vnc, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 20cafa1abb0e..377e7e6f7623 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8614,6 +8614,7 @@ qemuBuildGraphicsDBusCommandLine(virQEMUDriver *drive= r, virCommand *cmd, virDomainGraphicsDef *graphics) { + g_autofree char *charAlias =3D NULL; g_auto(virBuffer) opt =3D VIR_BUFFER_INITIALIZER; =20 if (!graphics->data.dbus.p2p && !graphics->data.dbus.address) { @@ -8648,6 +8649,17 @@ qemuBuildGraphicsDBusCommandLine(virQEMUDriver *driv= er, virCommandAddArg(cmd, "-display"); virCommandAddArgBuffer(cmd, &opt); =20 + + if (graphics->data.dbus.copypaste =3D=3D VIR_TRISTATE_BOOL_YES) { + if (!(charAlias =3D qemuAliasChardevFromDevAlias("qemu-vdagent"))) + return -1; + + virBufferAsprintf(&opt, "qemu-vdagent,id=3D%s", charAlias); + virBufferAddLit(&opt, ",clipboard=3Don"); + virCommandAddArg(cmd, "-chardev"); + virCommandAddArgBuffer(cmd, &opt); + } + return 0; } =20 diff --git a/tests/qemuxml2argvdata/graphics-dbus-clipboard.args b/tests/qe= muxml2argvdata/graphics-dbus-clipboard.args new file mode 100644 index 000000000000..a2de21f73130 --- /dev/null +++ b/tests/qemuxml2argvdata/graphics-dbus-clipboard.args @@ -0,0 +1,32 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-i386 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,file=3D/tmp/lib/domain--1-QEMU= Guest1/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-realtime mlock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-usb \ +-drive file=3D/dev/HostVG/QEMUGuest1,format=3Draw,if=3Dnone,id=3Ddrive-ide= 0-0-0 \ +-device ide-hd,bus=3Dide.0,unit=3D0,drive=3Ddrive-ide0-0-0,id=3Dide0-0-0,b= ootindex=3D1 \ +-display dbus,p2p=3Don \ +-chardev qemu-vdagent,id=3Dcharqemu-vdagent,clipboard=3Don \ +-device cirrus-vga,id=3Dvideo0,bus=3Dpci.0,addr=3D0x2 \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/graphics-dbus-clipboard.xml b/tests/qem= uxml2argvdata/graphics-dbus-clipboard.xml new file mode 100644 index 000000000000..e6bf7c6b88a1 --- /dev/null +++ b/tests/qemuxml2argvdata/graphics-dbus-clipboard.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e5454f03eccf..e1f032fe8a79 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1526,6 +1526,10 @@ mymain(void) QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS); DO_TEST("graphics-dbus-audio", QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DISPLAY_DBUS, QEMU_CAPS= _AUDIODEV); + DO_TEST("graphics-dbus-clipboard", + QEMU_CAPS_DEVICE_CIRRUS_VGA, + QEMU_CAPS_DISPLAY_DBUS, + QEMU_CAPS_CHARDEV_VDAGENT); =20 DO_TEST_NOCAPS("input-usbmouse"); DO_TEST_NOCAPS("input-usbtablet"); --=20 2.33.0.721.g106298f7f9