From nobody Mon Feb 9 09:08:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1620728237; cv=none; d=zohomail.com; s=zohoarc; b=OwWMp0IeVcy3ZAIgI4Rz7EA9U8rOJOaWktRliLzGHUSPdF+mYpruvmD86zoU3RqKrW5Wtv5wyKW8BH/uAJ5Kp/MyIsUsp1u2PLTPON0giGy5P/FQjvxcpaFhruZ4QCOLCfIuxPydFMZlfP/gg/BwyAxJ6A5eKDt/UGDAEQ2BBqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620728237; h=Content-Type:Content-Transfer-Encoding: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=HO0VuKZB1VK4KcZ0gi00SfJf+YQpv0nEwjnE/PD9SvE=; b=eWF53nrgl4uuQuJLV8x33JIFd139fN7NWzN1P/QpCDtae3W/TRbAFdhOPdM67Tn/g0/KeuClkFdpHhrRjCq2Z2g7jEyjR0Y4o0DCGkxiyunTPtOuNyM2N+8hXzl2Temj+8+xR82gIHjS30I9WYKPodtJ1swyczBHieieeNYG1DQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620728237801328.7649131300733; Tue, 11 May 2021 03:17:17 -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-29-5SFt7mvZM4-dNDya67x7qw-1; Tue, 11 May 2021 06:17:14 -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 75AD118C35CF; Tue, 11 May 2021 10:17:08 +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 4CFEA62499; Tue, 11 May 2021 10:17:08 +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 F2D17180B463; Tue, 11 May 2021 10:17:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14BAGrm6011659 for ; Tue, 11 May 2021 06:16:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id E35CD63746; Tue, 11 May 2021 10:16:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.195.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48F2163C40 for ; Tue, 11 May 2021 10:16:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620728236; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=HO0VuKZB1VK4KcZ0gi00SfJf+YQpv0nEwjnE/PD9SvE=; b=Cst7DtnzqLBMldh5b8Vq/8579QeuTczVgG0EFmWPOAJlihtdTMmnW7E0TGUfoLAGGa/e6E 0hZxwGlRkJ4jMoISdOkEnwBjW425rr6ToOh6pYrN3hpgg5aCVXpme/f6wwCaTW22eIB0CV BvmcfH93Ev7sy2S7p6mU1XGay2h77hs= X-MC-Unique: 5SFt7mvZM4-dNDya67x7qw-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 3/3] qemu: Build command line for object input-linux Date: Tue, 11 May 2021 12:16:12 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Resolves: https://gitlab.com/libvirt/libvirt/-/issues/142 Signed-off-by: Kristina Hanicova --- src/qemu/qemu_command.c | 32 ++++++++++++++++- .../input-linux.x86_64-latest.args | 34 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/input-linux.x86_64-latest.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 41f0b1d1d5..a1354d6fbd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4065,6 +4065,29 @@ qemuBuildUSBInputDevStr(const virDomainDef *def, } =20 =20 +static char * +qemuBuildObjectInputDevStr(virDomainInputDef *dev, + virQEMUCaps *qemuCaps) +{ + g_autoptr(virJSONValue) props =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + if (qemuMonitorCreateObjectProps(&props, "input-linux", dev->info.alia= s, + "s:evdev", dev->source.evdev, + "T:repeat", dev->source.repeat, + NULL) < 0) + return NULL; + + if (dev->source.grab =3D=3D VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL) + virJSONValueObjectAdd(props, "b:grab_all", true, NULL); + + if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + return NULL; + + return virBufferContentAndReset(&buf); +} + + int qemuBuildInputDevStr(char **devstr, const virDomainDef *def, @@ -4081,6 +4104,10 @@ qemuBuildInputDevStr(char **devstr, if (!(*devstr =3D qemuBuildVirtioInputDevStr(def, input, qemuCaps)= )) return -1; break; + case VIR_DOMAIN_INPUT_BUS_NONE: + if (!(*devstr =3D qemuBuildObjectInputDevStr(input, qemuCaps))) + return -1; + break; } return 0; } @@ -4104,7 +4131,10 @@ qemuBuildInputCommandLine(virCommand *cmd, return -1; =20 if (devstr) { - virCommandAddArg(cmd, "-device"); + if (input->type =3D=3D VIR_DOMAIN_INPUT_TYPE_EVDEV) + virCommandAddArg(cmd, "-object"); + else + virCommandAddArg(cmd, "-device"); virCommandAddArg(cmd, devstr); } } diff --git a/tests/qemuxml2argvdata/input-linux.x86_64-latest.args b/tests/= qemuxml2argvdata/input-linux.x86_64-latest.args new file mode 100644 index 0000000000..688cf02873 --- /dev/null +++ b/tests/qemuxml2argvdata/input-linux.x86_64-latest.args @@ -0,0 +1,34 @@ +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 '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dp= c.ram \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-object '{"qom-type":"input-linux","id":"input0","evdev":"/dev/input/event= 1234","repeat":true,"grab_all":true}' \ +-audiodev id=3Daudio1,driver=3Dnone \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x2 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a9dafe226e..265427ab7b 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3259,6 +3259,8 @@ mymain(void) QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET); DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST); =20 + DO_TEST_CAPS_LATEST("input-linux"); + DO_TEST("ppc64-usb-controller", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_PCI_OHCI); --=20 2.31.1