From nobody Thu May 15 00:57:01 2025 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 1513788499187819.4654701374592; Wed, 20 Dec 2017 08:48:19 -0800 (PST) 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 A74DC7EAB0; Wed, 20 Dec 2017 16:48:17 +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 813755C549; Wed, 20 Dec 2017 16:48:17 +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 479471808873; Wed, 20 Dec 2017 16:48:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBKGm5a4008458 for ; Wed, 20 Dec 2017 11:48:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 50DAD18E33; Wed, 20 Dec 2017 16:48:05 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFBC360C31; Wed, 20 Dec 2017 16:48:03 +0000 (UTC) From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Wed, 20 Dec 2017 16:47:48 +0000 Message-Id: <20171220164750.26419-4-berrange@redhat.com> In-Reply-To: <20171220164750.26419-1-berrange@redhat.com> References: <20171220164750.26419-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Martin Kletzander , David Vossel , Fabian Deutsch Subject: [libvirt] [PATCH 3/5] qemu: add a public API to trigger QEMU driver to connect to running guest 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.28]); Wed, 20 Dec 2017 16:48:18 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently the QEMU driver will reconnect to running guests during libvirtd startup. To support the ability to launch a fully supported guest externally to the main libvirtd daemon, this adds a QEMU specific public API virDomainQemuReconnect(conn, name, flags); This accepts a domain name, and simply runs the normal reconnect logic that the QEMU driver would do at startup. Signed-off-by: Daniel P. Berrange --- include/libvirt/libvirt-qemu.h | 4 ++++ src/driver-hypervisor.h | 5 +++++ src/libvirt-qemu.c | 48 ++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_qemu.syms | 5 +++++ src/remote/qemu_protocol.x | 18 +++++++++++++++- src/remote/remote_driver.c | 1 + 6 files changed, 80 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h index 2bb8ee8685..0d38d2f9f8 100644 --- a/include/libvirt/libvirt-qemu.h +++ b/include/libvirt/libvirt-qemu.h @@ -44,6 +44,10 @@ virDomainPtr virDomainQemuAttach(virConnectPtr domain, unsigned int pid_value, unsigned int flags); =20 +virDomainPtr virDomainQemuReconnect(virConnectPtr domain, + const char *name, + unsigned int flags); + typedef enum { VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN =3D -2, VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK =3D -2, diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index ce0e2b2525..2e923e730f 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -848,6 +848,10 @@ typedef virDomainPtr (*virDrvDomainQemuAttach)(virConnectPtr conn, unsigned int pid_value, unsigned int flags); +typedef virDomainPtr +(*virDrvDomainQemuReconnect)(virConnectPtr conn, + const char *name, + unsigned int flags); =20 typedef int (*virDrvConnectDomainQemuMonitorEventRegister)(virConnectPtr conn, @@ -1463,6 +1467,7 @@ struct _virHypervisorDriver { virDrvDomainSnapshotDelete domainSnapshotDelete; virDrvDomainQemuMonitorCommand domainQemuMonitorCommand; virDrvDomainQemuAttach domainQemuAttach; + virDrvDomainQemuReconnect domainQemuReconnect; virDrvDomainQemuAgentCommand domainQemuAgentCommand; virDrvConnectDomainQemuMonitorEventRegister connectDomainQemuMonitorEv= entRegister; virDrvConnectDomainQemuMonitorEventDeregister connectDomainQemuMonitor= EventDeregister; diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 43f63839eb..c5859cf312 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -164,6 +164,54 @@ virDomainQemuAttach(virConnectPtr conn, return NULL; } =20 +/** + * virDomainQemuReconnect: + * @conn: pointer to a hypervisor connection + * @name: the libvirt guest name + * @flags: optional flags, currently unused + * + * This API is QEMU specific, so it will only work with hypervisor + * connections to the QEMU driver. + * + * This API will attach to an QEMU process that a separate libvirt + * helper has launched. The external QEMU must fully follow the + * normal libvirt QEMU configuration. + * + * If successful, then the guest will appear in the list of running + * domains for this connection, and other APIs should operate + * normally (provided the above requirements were honored). + * + * Returns a new domain object on success, NULL otherwise + */ +virDomainPtr +virDomainQemuReconnect(virConnectPtr conn, + const char *name, + unsigned int flags) +{ + VIR_DEBUG("conn=3D%p, name=3D%s, flags=3D0x%x", conn, name, flags); + + virResetLastError(); + + virCheckConnectReturn(conn, NULL); + virCheckNonNullArgGoto(name, error); + + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainQemuReconnect) { + virDomainPtr ret; + ret =3D conn->driver->domainQemuReconnect(conn, name, flags); + if (!ret) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return NULL; +} + =20 /** * virDomainQemuAgentCommand: diff --git a/src/libvirt_qemu.syms b/src/libvirt_qemu.syms index 3a297e3a2b..a109fcc0d0 100644 --- a/src/libvirt_qemu.syms +++ b/src/libvirt_qemu.syms @@ -30,3 +30,8 @@ LIBVIRT_QEMU_1.2.3 { virConnectDomainQemuMonitorEventDeregister; virConnectDomainQemuMonitorEventRegister; } LIBVIRT_QEMU_0.10.0; + +LIBVIRT_QEMU_4.1.0 { + global: + virDomainQemuReconnect; +} LIBVIRT_QEMU_1.2.3; diff --git a/src/remote/qemu_protocol.x b/src/remote/qemu_protocol.x index f6b88a984c..b5307bf9dd 100644 --- a/src/remote/qemu_protocol.x +++ b/src/remote/qemu_protocol.x @@ -82,6 +82,15 @@ struct qemu_domain_monitor_event_msg { remote_string details; }; =20 +struct qemu_domain_reconnect_args { + remote_nonnull_string name; + unsigned int flags; +}; + +struct qemu_domain_reconnect_ret { + remote_nonnull_domain dom; +}; + /* Define the program number, protocol version and procedure numbers here.= */ const QEMU_PROGRAM =3D 0x20008087; const QEMU_PROTOCOL_VERSION =3D 1; @@ -154,5 +163,12 @@ enum qemu_procedure { * @generate: both * @acl: none */ - QEMU_PROC_DOMAIN_MONITOR_EVENT =3D 6 + QEMU_PROC_DOMAIN_MONITOR_EVENT =3D 6, + + /** + * @generate: both + * @acl: domain:start + * @acl: domain:write + */ + QEMU_PROC_DOMAIN_RECONNECT =3D 7 }; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index f8fa64af99..b76242fe2e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8431,6 +8431,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainSnapshotDelete =3D remoteDomainSnapshotDelete, /* 0.8.0 */ .domainQemuMonitorCommand =3D remoteDomainQemuMonitorCommand, /* 0.8.3= */ .domainQemuAttach =3D remoteDomainQemuAttach, /* 0.9.4 */ + .domainQemuReconnect =3D remoteDomainQemuReconnect, /* 4.1.0 */ .domainQemuAgentCommand =3D remoteDomainQemuAgentCommand, /* 0.10.0 */ .connectDomainQemuMonitorEventRegister =3D remoteConnectDomainQemuMoni= torEventRegister, /* 1.2.3 */ .connectDomainQemuMonitorEventDeregister =3D remoteConnectDomainQemuMo= nitorEventDeregister, /* 1.2.3 */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list