From nobody Mon Feb 9 09:29:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508252744893137.82845122042; Tue, 17 Oct 2017 08:05:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 329AB7E453; Tue, 17 Oct 2017 15:05:41 +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 E9EC161793; Tue, 17 Oct 2017 15:05:40 +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 E3CAD180BAE5; Tue, 17 Oct 2017 15:05:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9HF4vGZ003139 for ; Tue, 17 Oct 2017 11:04:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB3596061E; Tue, 17 Oct 2017 15:04:57 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 312D060603 for ; Tue, 17 Oct 2017 15:04:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 329AB7E453 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 17 Oct 2017 17:04:42 +0200 Message-Id: <925f444afcbdff0e587e5c5e485700d30296ac56.1508252637.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/12] Introduce qemuBuildInputDevStr 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 17 Oct 2017 15:05:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A function that builds the -device string for input devices. --- src/qemu/qemu_command.c | 42 +++++++++++++++++++++++++++++------------- src/qemu/qemu_command.h | 7 +++++++ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 138bbdf1a..7bdff85fc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4303,6 +4303,27 @@ qemuBuildUSBInputDevStr(const virDomainDef *def, } =20 =20 +int +qemuBuildInputDevStr(char **devstr, + const virDomainDef *def, + virDomainInputDefPtr input, + virQEMUCapsPtr qemuCaps) +{ + switch (input->bus) { + case VIR_DOMAIN_INPUT_BUS_USB: + if (!(*devstr =3D qemuBuildUSBInputDevStr(def, input, qemuCaps))) + return -1; + break; + + case VIR_DOMAIN_INPUT_BUS_VIRTIO: + if (!(*devstr =3D qemuBuildVirtioInputDevStr(def, input, qemuCaps)= )) + return -1; + break; + } + return 0; +} + + static int qemuBuildInputCommandLine(virCommandPtr cmd, const virDomainDef *def, @@ -4312,22 +4333,17 @@ qemuBuildInputCommandLine(virCommandPtr cmd, =20 for (i =3D 0; i < def->ninputs; i++) { virDomainInputDefPtr input =3D def->inputs[i]; + char *devstr =3D NULL; =20 - if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_USB) { - char *optstr; - virCommandAddArg(cmd, "-device"); - if (!(optstr =3D qemuBuildUSBInputDevStr(def, input, qemuCaps)= )) - return -1; - virCommandAddArg(cmd, optstr); - VIR_FREE(optstr); - } else if (input->bus =3D=3D VIR_DOMAIN_INPUT_BUS_VIRTIO) { - char *optstr; + if (qemuBuildInputDevStr(&devstr, def, input, qemuCaps) < 0) + return -1; + + if (devstr) { virCommandAddArg(cmd, "-device"); - if (!(optstr =3D qemuBuildVirtioInputDevStr(def, input, qemuCa= ps))) - return -1; - virCommandAddArg(cmd, optstr); - VIR_FREE(optstr); + virCommandAddArg(cmd, devstr); } + + VIR_FREE(devstr); } =20 return 0; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 1254ad4df..0961ec8cb 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -204,4 +204,11 @@ char *qemuBuildWatchdogDevStr(const virDomainDef *def, virDomainWatchdogDefPtr dev, virQEMUCapsPtr qemuCaps); =20 +int qemuBuildInputDevStr(char **devstr, + const virDomainDef *def, + virDomainInputDefPtr input, + virQEMUCapsPtr qemuCaps) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) + ATTRIBUTE_NONNULL(4); + #endif /* __QEMU_COMMAND_H__*/ --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list