From nobody Sun May 5 18:30:59 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526918905581727.4101799425592; Mon, 21 May 2018 09:08:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D5F73152E5D; Mon, 21 May 2018 16:08: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 849EA2010CEA; Mon, 21 May 2018 16:08:23 +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 27542180B5AA; Mon, 21 May 2018 16:08:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LG8JCn030393 for ; Mon, 21 May 2018 12:08:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C432AFD7F; Mon, 21 May 2018 16:08:19 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00195C1FB4 for ; Mon, 21 May 2018 16:08:18 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 21 May 2018 18:07:58 +0200 Message-Id: <95409f327911ddfe1dd34df2a1974677a61acc12.1526918750.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/5] Introduce virDomainDetachDeviceAlias API 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.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 21 May 2018 16:08:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When detaching a device it can be uniquely identified by its alias. Instead of misusing virDomainDetachDeviceFlags which has the same signature introduce new function. Signed-off-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 3 +++ src/driver-hypervisor.h | 6 ++++++ src/libvirt-domain.c | 46 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 5 +++++ 4 files changed, 60 insertions(+) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index d7cbd18796..da773b76cb 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2022,6 +2022,9 @@ int virDomainDetachDeviceFlags(virDomainPtr domain, int virDomainUpdateDeviceFlags(virDomainPtr domain, const char *xml, unsigned int flags); =20 +int virDomainDetachDeviceAlias(virDomainPtr domain, + const char *alias, unsigned int flags); + typedef struct _virDomainStatsRecord virDomainStatsRecord; typedef virDomainStatsRecord *virDomainStatsRecordPtr; struct _virDomainStatsRecord { diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index e71a72a441..9a224998fd 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -441,6 +441,11 @@ typedef int const char *xml, unsigned int flags); =20 +typedef int +(*virDrvDomainDetachDeviceAlias)(virDomainPtr domain, + const char *alias, + unsigned int flags); + typedef int (*virDrvDomainGetAutostart)(virDomainPtr domain, int *autostart); @@ -1392,6 +1397,7 @@ struct _virHypervisorDriver { virDrvDomainDetachDevice domainDetachDevice; virDrvDomainDetachDeviceFlags domainDetachDeviceFlags; virDrvDomainUpdateDeviceFlags domainUpdateDeviceFlags; + virDrvDomainDetachDeviceAlias domainDetachDeviceAlias; virDrvDomainGetAutostart domainGetAutostart; virDrvDomainSetAutostart domainSetAutostart; virDrvDomainGetSchedulerType domainGetSchedulerType; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 2d86e48979..b32c1d3064 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -8349,6 +8349,52 @@ virDomainUpdateDeviceFlags(virDomainPtr domain, } =20 =20 +/** + * virDomainDetachDeviceAlias: + * @domain: pointer to domain object + * @alias: device alias + * @flags: bitwise-OR of virDomainDeviceModifyFlags + * + * Detach a virtual device from a domain, using the alias to + * specify device. + * + * See virDomainDetachDeviceFlags() for more details. + * + * Returns 0 in case of success, -1 in case of failure. + */ +int +virDomainDetachDeviceAlias(virDomainPtr domain, + const char *alias, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "alias=3D%s, flags=3D0x%x", alias, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + conn =3D domain->conn; + + virCheckNonNullArgGoto(alias, error); + virCheckReadOnlyGoto(conn->flags, error); + + if (conn->driver->domainDetachDeviceAlias) { + int ret; + ret =3D conn->driver->domainDetachDeviceAlias(domain, alias, flags= ); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} + + /** * virConnectDomainEventRegister: * @conn: pointer to the connection diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 95df3a0dbc..cd6b0c1fdc 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -785,4 +785,9 @@ LIBVIRT_4.1.0 { virStoragePoolLookupByTargetPath; } LIBVIRT_3.9.0; =20 +LIBVIRT_4.4.0 { + global: + virDomainDetachDeviceAlias; +} LIBVIRT_4.1.0; + # .... define new API here using predicted next version number .... --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 18:30:59 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152691891675471.63450811406233; Mon, 21 May 2018 09:08:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F9DFC11382A; Mon, 21 May 2018 16:08:35 +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 00A2A28DDA; Mon, 21 May 2018 16:08:34 +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 A58B34CA95; Mon, 21 May 2018 16:08:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LG8KFn030395 for ; Mon, 21 May 2018 12:08:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id F0267C1FB3; Mon, 21 May 2018 16:08:19 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95699BDC5B for ; Mon, 21 May 2018 16:08:19 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 21 May 2018 18:07:59 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/5] remote: Implement virDomainDetachDeviceAlias 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 21 May 2018 16:08:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 16 +++++++++++++++- src/remote_protocol-structs | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 95437b4365..8695046b71 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8308,6 +8308,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainDetachDevice =3D remoteDomainDetachDevice, /* 0.3.0 */ .domainDetachDeviceFlags =3D remoteDomainDetachDeviceFlags, /* 0.7.7 */ .domainUpdateDeviceFlags =3D remoteDomainUpdateDeviceFlags, /* 0.8.0 */ + .domainDetachDeviceAlias =3D remoteDomainDetachDeviceAlias, /* 4.4.0 */ .domainGetAutostart =3D remoteDomainGetAutostart, /* 0.3.0 */ .domainSetAutostart =3D remoteDomainSetAutostart, /* 0.3.0 */ .domainGetSchedulerType =3D remoteDomainGetSchedulerType, /* 0.3.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 296a087181..b23c93514a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -1284,6 +1284,12 @@ struct remote_domain_update_device_flags_args { unsigned int flags; }; =20 +struct remote_domain_detach_device_alias_args { + remote_nonnull_domain dom; + remote_nonnull_string alias; + unsigned int flags; +}; + struct remote_domain_get_autostart_args { remote_nonnull_domain dom; }; @@ -6135,5 +6141,13 @@ enum remote_procedure { * @priority: high * @acl: storage_pool:getattr */ - REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH =3D 391 + REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH =3D 391, + + /** + * @generate: both + * @acl: domain:write + * @acl: domain:save:!VIR_DOMAIN_AFFECT_CONFIG|VIR_DOMAIN_AFFECT_LIVE + * @acl: domain:save:VIR_DOMAIN_AFFECT_CONFIG + */ + REMOTE_PROC_DOMAIN_DETACH_DEVICE_ALIAS =3D 392 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index fe163db73f..1b4fbc5d4b 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -915,6 +915,11 @@ struct remote_domain_update_device_flags_args { remote_nonnull_string xml; u_int flags; }; +struct remote_domain_detach_device_alias_args { + remote_nonnull_domain dom; + remote_nonnull_string alias; + u_int flags; +}; struct remote_domain_get_autostart_args { remote_nonnull_domain dom; }; @@ -3269,4 +3274,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML =3D 389, REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION =3D 390, REMOTE_PROC_STORAGE_POOL_LOOKUP_BY_TARGET_PATH =3D 391, + REMOTE_PROC_DOMAIN_DETACH_DEVICE_ALIAS =3D 392, }; --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 18:30:59 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526918916932350.6560791913072; Mon, 21 May 2018 09:08:36 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2CC8E30C2869; Mon, 21 May 2018 16:08:35 +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 ED88B600CC; Mon, 21 May 2018 16:08:34 +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 A41394CA94; Mon, 21 May 2018 16:08:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LG8KIM030424 for ; Mon, 21 May 2018 12:08:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90C5585778; Mon, 21 May 2018 16:08:20 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36208AFD7F for ; Mon, 21 May 2018 16:08:20 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 21 May 2018 18:08:00 +0200 Message-Id: <5eea36e9f82a8a9ecd3ef6b385d492c18a0e5af0.1526918750.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] qemu: Split qemuDomainDetachDeviceLiveAndConfig 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 21 May 2018 16:08:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The aim is to have qemuDomainDetachDeviceLiveAndConfig() accept virDomainDeviceDefPtr. Therefore, new qemuDomainDetachDeviceXMLLiveAndConfig() which is a drop in replacement for the former. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a328e5d46..0e0c0ce53e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8661,15 +8661,16 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr= dom, return ret; } =20 + static int qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver, virDomainObjPtr vm, - const char *xml, + virDomainDeviceDefPtr dev, unsigned int flags) { virCapsPtr caps =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; - virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; + virDomainDeviceDefPtr dev_copy =3D dev; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; virDomainDefPtr vmdef =3D NULL; int ret =3D -1; @@ -8686,12 +8687,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr= driver, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, - parse_flags); - if (dev =3D=3D NULL) - goto cleanup; - if (flags & VIR_DOMAIN_AFFECT_CONFIG && flags & VIR_DOMAIN_AFFECT_LIVE) { /* If we are affecting both CONFIG and LIVE @@ -8743,11 +8738,42 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPt= r driver, virObjectUnref(cfg); if (dev !=3D dev_copy) virDomainDeviceDefFree(dev_copy); - virDomainDeviceDefFree(dev); virDomainDefFree(vmdef); return ret; } =20 + +static int +qemuDomainDetachDeviceXMLLiveAndConfig(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *xml, + unsigned int flags) +{ + virCapsPtr caps =3D NULL; + virDomainDeviceDefPtr dev =3D NULL; + unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; + int ret =3D -1; + + if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + goto cleanup; + + if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && + !(flags & VIR_DOMAIN_AFFECT_LIVE)) + parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; + + if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, + caps, driver->xmlopt, + parse_flags))) + goto cleanup; + + ret =3D qemuDomainDetachDeviceLiveAndConfig(driver, vm, dev, flags); + cleanup: + virDomainDeviceDefFree(dev); + virObjectUnref(caps); + return ret; +} + + static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, @@ -8769,7 +8795,7 @@ qemuDomainDetachDeviceFlags(virDomainPtr dom, if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) goto endjob; =20 - if (qemuDomainDetachDeviceLiveAndConfig(driver, vm, xml, flags) < 0) + if (qemuDomainDetachDeviceXMLLiveAndConfig(driver, vm, xml, flags) < 0) goto endjob; =20 ret =3D 0; --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 18:30:59 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526918922093547.9673712529823; Mon, 21 May 2018 09:08:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 724373116B3A; Mon, 21 May 2018 16:08:40 +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 4624C28DDC; Mon, 21 May 2018 16:08: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 EC19E1801256; Mon, 21 May 2018 16:08:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LG8LPC030446 for ; Mon, 21 May 2018 12:08:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 315B985778; Mon, 21 May 2018 16:08:21 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAEA7BDC5B for ; Mon, 21 May 2018 16:08:20 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 21 May 2018 18:08:01 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] qemu: Implement virDomainDetachDeviceAlias 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 21 May 2018 16:08:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0e0c0ce53e..fee152d202 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8808,6 +8808,46 @@ qemuDomainDetachDeviceFlags(virDomainPtr dom, return ret; } =20 + +static int +qemuDomainDetachDeviceAlias(virDomainPtr dom, + const char *alias, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + virDomainDeviceDef dev; + int ret =3D -1; + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainDetachDeviceAliasEnsureACL(dom->conn, vm->def, flags) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainDefFindDevice(vm->def, alias, &dev, true) < 0) + goto endjob; + + if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) + goto endjob; + + if (qemuDomainDetachDeviceLiveAndConfig(driver, vm, &dev, flags) < 0) + goto endjob; + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + + static int qemuDomainDetachDevice(virDomainPtr dom, const char *xml) { return qemuDomainDetachDeviceFlags(dom, xml, @@ -21303,6 +21343,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainDetachDevice =3D qemuDomainDetachDevice, /* 0.5.0 */ .domainDetachDeviceFlags =3D qemuDomainDetachDeviceFlags, /* 0.7.7 */ .domainUpdateDeviceFlags =3D qemuDomainUpdateDeviceFlags, /* 0.8.0 */ + .domainDetachDeviceAlias =3D qemuDomainDetachDeviceAlias, /* 4.4.0 */ .domainGetAutostart =3D qemuDomainGetAutostart, /* 0.2.1 */ .domainSetAutostart =3D qemuDomainSetAutostart, /* 0.2.1 */ .domainGetSchedulerType =3D qemuDomainGetSchedulerType, /* 0.7.0 */ --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 18:30:59 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526918927119735.3376826296446; Mon, 21 May 2018 09:08:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5278634ADEF; Mon, 21 May 2018 16:08:45 +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 29794977B2; Mon, 21 May 2018 16:08:45 +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 DA9C61801255; Mon, 21 May 2018 16:08:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LG8LYX030459 for ; Mon, 21 May 2018 12:08:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id C641885778; Mon, 21 May 2018 16:08:21 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B8FAC1FB4 for ; Mon, 21 May 2018 16:08:21 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 21 May 2018 18:08:02 +0200 Message-Id: <4cdbf233a93cf3ad46d3aa4c2909e98dba5732cd.1526918751.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/5] virsh: Expose virDomainDetachDeviceAlias 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 21 May 2018 16:08:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik --- tools/virsh-domain.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 15 ++++++++++ 2 files changed, 94 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cfbbf5a7bc..b41e76b3d8 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11878,6 +11878,79 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) return funcRet; } =20 + +/* + * "detach-device-alias" command + */ +static const vshCmdInfo info_detach_device_alias[] =3D { + {.name =3D "help", + .data =3D N_("detach device from an alias") + }, + {.name =3D "desc", + .data =3D N_("Detach device from domain using given alias to identify= device") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_detach_device_alias[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL(0), + {.name =3D "alias", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("device alias") + }, + VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, + VIRSH_COMMON_OPT_DOMAIN_CONFIG, + VIRSH_COMMON_OPT_DOMAIN_LIVE, + VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name =3D NULL} +}; + +static bool +cmdDetachDeviceAlias(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom =3D NULL; + const char *alias =3D NULL; + bool current =3D vshCommandOptBool(cmd, "current"); + bool config =3D vshCommandOptBool(cmd, "config"); + bool live =3D vshCommandOptBool(cmd, "live"); + bool persistent =3D vshCommandOptBool(cmd, "persistent"); + unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; + bool ret =3D false; + + VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current); + VSH_EXCLUSIVE_OPTIONS_VAR(current, live); + VSH_EXCLUSIVE_OPTIONS_VAR(current, config); + + if (config || persistent) + flags |=3D VIR_DOMAIN_AFFECT_CONFIG; + if (live) + flags |=3D VIR_DOMAIN_AFFECT_LIVE; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (persistent && + virDomainIsActive(dom) =3D=3D 1) + flags |=3D VIR_DOMAIN_AFFECT_LIVE; + + if (vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0) + goto cleanup; + + if (virDomainDetachDeviceAlias(dom, alias, flags) < 0) { + vshError(ctl, _("Failed to detach device with alias %s"), alias); + goto cleanup; + } + + vshPrintExtra(ctl, "%s", _("Device detached successfully\n")); + ret =3D true; + + cleanup: + virshDomainFree(dom); + return ret; +} + + /* * "update-device" command */ @@ -13999,6 +14072,12 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_detach_device, .flags =3D 0 }, + {.name =3D "detach-device-alias", + .handler =3D cmdDetachDeviceAlias, + .opts =3D opts_detach_device_alias, + .info =3D info_detach_device_alias, + .flags =3D 0 + }, {.name =3D "detach-disk", .handler =3D cmdDetachDisk, .opts =3D opts_detach_disk, diff --git a/tools/virsh.pod b/tools/virsh.pod index 929958a953..b6e60ce2f7 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3112,6 +3112,21 @@ an offline domain, and like I<--live> I<--config> fo= r a running domain. Note that older versions of virsh used I<--config> as an alias for I<--persistent>. =20 +=3Ditem B I I +[[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] + +Detach a device with given I from the I. + +If I<--live> is specified, affect a running domain. +If I<--config> is specified, affect the next startup of a persistent domai= n. +If I<--current> is specified, affect the current domain state. +Both I<--live> and I<--config> flags may be given, but I<--current> is +exclusive. When no flag is specified legacy API is used whose behavior dep= ends +on the hypervisor driver. + +For compatibility purposes, I<--persistent> behaves like I<--config> for +an offline domain, and like I<--live> I<--config> for a running domain. + =3Ditem B I I [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] [I<--print-xml>] --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list