From nobody Mon Feb 9 07:38:21 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=1643899950; cv=none; d=zohomail.com; s=zohoarc; b=MjpTTLv2mCPuFOgIBpIJfwi+juG3v8SsXr0SD6FyNKVcMA4+svI33p4c6DIyPWxKdbsnpQOvKBF75MTawNTvF7B7haP+t1sbqgt6fap5IbbetrduJAUhfntDQWxzdryUk3+WktrYEmneEeMAvODxnjwtu+VdSQpaqCNc5N73M1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643899950; 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=VpsveF0fCTq0UOt4kRcYx8IeJ67w6Y9K45/ZjxPCHkw=; b=A7ZGzN0sZ7OOEUUtnp4yeYenDSuNfAni3LTMDHjSSHawNAg63YcBMilazp/gRTTSHZVFYEJs/Cn2xkBz4J/jLn5yyl5Y/cNvatI6mPMHzd2FvZ2l+QhG7OCCSpKXoU0M/nrdrxFAclYtC0YaPggOdrwdc0u+CVbsi7I4veMY/NQ= 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 1643899950144108.48296316196365; Thu, 3 Feb 2022 06:52:30 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-rLcbOXGkNtaRXux0DMJI_Q-1; Thu, 03 Feb 2022 09:52:28 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89341101AFD3; Thu, 3 Feb 2022 14:52:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 236D870D39; Thu, 3 Feb 2022 14:52:19 +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 DA39C4CA93; Thu, 3 Feb 2022 14:52:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 213EqESn029457 for ; Thu, 3 Feb 2022 09:52:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id C919B70D33; Thu, 3 Feb 2022 14:52:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.41]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06EF970D30 for ; Thu, 3 Feb 2022 14:52:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643899949; 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=VpsveF0fCTq0UOt4kRcYx8IeJ67w6Y9K45/ZjxPCHkw=; b=A2lxFjO31t0SFJ6jPjmFONdUmsF4KrzLsSn6pxCy+AnJ5jbsOnX8AcgQX55hYQSCBDZJ0q onyifIWJXce4OMp/HZCjDnnITmMVpu+/DvSeM2iI2VkJpUFIKbfYsfYv0kFblXgGz2/mq5 kBQ3gEJhg6Y9eJxtCMUWIQxg/x34WAA= X-MC-Unique: rLcbOXGkNtaRXux0DMJI_Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] qemu: Implement qemuDomainQemuMonitorCommandWithFiles Date: Thu, 3 Feb 2022 15:51:59 +0100 Message-Id: <4c749f03d12db46158c271a1ec67864287cb49c4.1643899820.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.11 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) X-ZM-MESSAGEID: 1643899951526100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 34 ++++++++++++++++++++++++++++++---- src/qemu/qemu_monitor.c | 7 ++++--- src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 6 ++++-- src/qemu/qemu_monitor_json.h | 2 ++ src/qemu/qemu_monitor_text.c | 8 ++++---- 6 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 698f57f00e..d10d1556a7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13897,21 +13897,36 @@ qemuDomainBackupGetXMLDesc(virDomainPtr domain, } -static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *c= md, - char **result, unsigned int flags) +static int +qemuDomainQemuMonitorCommandWithFiles(virDomainPtr domain, + const char *cmd, + unsigned int nfds, + int *fds, + char **result, + unsigned int flags) { virQEMUDriver *driver =3D domain->conn->privateData; virDomainObj *vm =3D NULL; int ret =3D -1; qemuDomainObjPrivate *priv; bool hmp; + int fd =3D -1; virCheckFlags(VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP, -1); + if (nfds > 1) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("at most 1 fd can be passed to qemu along with a = command")); + return -1; + } + + if (nfds =3D=3D 1) + fd =3D fds[0]; + if (!(vm =3D qemuDomainObjFromDomain(domain))) goto cleanup; - if (virDomainQemuMonitorCommandEnsureACL(domain->conn, vm->def) < 0) + if (virDomainQemuMonitorCommandWithFilesEnsureACL(domain->conn, vm->de= f) < 0) goto cleanup; if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0) @@ -13927,7 +13942,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPt= r domain, const char *cmd, hmp =3D !!(flags & VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP); qemuDomainObjEnterMonitor(driver, vm); - ret =3D qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp); + ret =3D qemuMonitorArbitraryCommand(priv->mon, cmd, fd, result, hmp); qemuDomainObjExitMonitor(driver, vm); endjob: @@ -13939,6 +13954,16 @@ static int qemuDomainQemuMonitorCommand(virDomainP= tr domain, const char *cmd, } +static int +qemuDomainQemuMonitorCommand(virDomainPtr domain, + const char *cmd, + char **result, + unsigned int flags) +{ + return qemuDomainQemuMonitorCommandWithFiles(domain, cmd, 0, NULL, res= ult, flags); +} + + static int qemuDomainOpenConsole(virDomainPtr dom, const char *dev_name, @@ -20849,6 +20874,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainRevertToSnapshot =3D qemuDomainRevertToSnapshot, /* 0.8.0 */ .domainSnapshotDelete =3D qemuDomainSnapshotDelete, /* 0.8.0 */ .domainQemuMonitorCommand =3D qemuDomainQemuMonitorCommand, /* 0.8.3 */ + .domainQemuMonitorCommandWithFiles =3D qemuDomainQemuMonitorCommandWit= hFiles, /* 8.1.0 */ .domainQemuAttach =3D NULL, /* 0.9.4 - 5.5.0 */ .domainQemuAgentCommand =3D qemuDomainQemuAgentCommand, /* 0.10.0 */ .connectDomainQemuMonitorEventRegister =3D qemuConnectDomainQemuMonito= rEventRegister, /* 1.2.3 */ diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index babf9e62fb..6359a05155 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3104,17 +3104,18 @@ qemuMonitorDrivePivot(qemuMonitor *mon, int qemuMonitorArbitraryCommand(qemuMonitor *mon, const char *cmd, + int fd, char **reply, bool hmp) { - VIR_DEBUG("cmd=3D%s, reply=3D%p, hmp=3D%d", cmd, reply, hmp); + VIR_DEBUG("cmd=3D%s, fd=3D%d, reply=3D%p, hmp=3D%d", cmd, fd, reply, h= mp); QEMU_CHECK_MONITOR(mon); if (hmp) - return qemuMonitorJSONHumanCommand(mon, cmd, reply); + return qemuMonitorJSONHumanCommand(mon, cmd, fd, reply); else - return qemuMonitorJSONArbitraryCommand(mon, cmd, reply); + return qemuMonitorJSONArbitraryCommand(mon, cmd, fd, reply); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 9b2e4e1421..b7ed8d9bae 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1108,6 +1108,7 @@ char *qemuMonitorDiskNameLookup(qemuMonitor *mon, int qemuMonitorArbitraryCommand(qemuMonitor *mon, const char *cmd, + int fd, char **reply, bool hmp); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index b0b513683b..9ab07bb29a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1461,6 +1461,7 @@ qemuMonitorJSONHandleGuestCrashloaded(qemuMonitor *mo= n, int qemuMonitorJSONHumanCommand(qemuMonitor *mon, const char *cmd_str, + int fd, char **reply_str) { g_autoptr(virJSONValue) cmd =3D NULL; @@ -1472,7 +1473,7 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon, "s:command-line", cmd_str, NULL); - if (!cmd || qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + if (!cmd || qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0) return -1; if (qemuMonitorJSONHasError(reply, "CommandNotFound")) { @@ -4497,6 +4498,7 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon, int qemuMonitorJSONArbitraryCommand(qemuMonitor *mon, const char *cmd_str, + int fd, char **reply_str) { g_autoptr(virJSONValue) cmd =3D NULL; @@ -4505,7 +4507,7 @@ int qemuMonitorJSONArbitraryCommand(qemuMonitor *mon, if (!(cmd =3D virJSONValueFromString(cmd_str))) return -1; - if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + if (qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0) return -1; if (!(*reply_str =3D virJSONValueToString(reply, false))) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 64d9ebdaa3..c57f54e040 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -43,6 +43,7 @@ qemuMonitorJSONIOProcess(qemuMonitor *mon, int qemuMonitorJSONHumanCommand(qemuMonitor *mon, const char *cmd, + int fd, char **reply); int @@ -369,6 +370,7 @@ qemuMonitorJSONDiskNameLookup(qemuMonitor *mon, int qemuMonitorJSONArbitraryCommand(qemuMonitor *mon, const char *cmd_str, + int fd, char **reply_str); int diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 0ca7f5a470..86af1e4975 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -43,7 +43,7 @@ int qemuMonitorTextAddDrive(qemuMonitor *mon, * address required when attaching drives to a controller */ cmd =3D g_strdup_printf("drive_add dummy %s", drivestr); - if (qemuMonitorJSONHumanCommand(mon, cmd, &reply) < 0) + if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply) < 0) return -1; if (strstr(reply, "unknown command:")) { @@ -93,7 +93,7 @@ int qemuMonitorTextDriveDel(qemuMonitor *mon, cmd =3D g_strdup_printf("drive_del %s", drivestr); - if (qemuMonitorJSONHumanCommand(mon, cmd, &reply) < 0) + if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply) < 0) return -1; if (strstr(reply, "unknown command:")) { @@ -124,7 +124,7 @@ qemuMonitorTextCreateSnapshot(qemuMonitor *mon, cmd =3D g_strdup_printf("savevm \"%s\"", name); - if (qemuMonitorJSONHumanCommand(mon, cmd, &reply)) + if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply)) return -1; if (strstr(reply, "Error while creating snapshot") || @@ -150,7 +150,7 @@ int qemuMonitorTextDeleteSnapshot(qemuMonitor *mon, con= st char *name) g_autofree char *reply =3D NULL; cmd =3D g_strdup_printf("delvm \"%s\"", name); - if (qemuMonitorJSONHumanCommand(mon, cmd, &reply)) + if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply)) return -1; if (strstr(reply, "No block device supports snapshots")) { --=20 2.34.1