From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152001740656.0558616879711; Mon, 16 Oct 2017 04:06:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA94F5AFED; Mon, 16 Oct 2017 11:06:39 +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 308D55CC1E; Mon, 16 Oct 2017 11:06:38 +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 030373FAD9; Mon, 16 Oct 2017 11:06:34 +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 v9GB6Wkm008657 for ; Mon, 16 Oct 2017 07:06:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id A29285D961; Mon, 16 Oct 2017 11:06:32 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 037055D964 for ; Mon, 16 Oct 2017 11:06:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA94F5AFED Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:14 +0200 Message-Id: <5962c287df8cfb1f1a3c9c60fd34b9009997558f.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/14] conf: rename lifecycle enum values to correspond with typedef keyword 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 16 Oct 2017 11:06:40 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 10 +++++----- src/libxl/libxl_conf.c | 12 ++++++------ src/libxl/libxl_domain.c | 20 ++++++++++---------- src/lxc/lxc_native.c | 4 ++-- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_driver.c | 8 ++++---- src/qemu/qemu_parse_command.c | 6 +++--- src/qemu/qemu_process.c | 4 ++-- src/test/test_driver.c | 8 ++++---- src/vmx/vmx.c | 4 ++-- src/vz/vz_sdk.c | 8 ++++---- src/xenapi/xenapi_utils.c | 10 +++++----- src/xenconfig/xen_sxpr.c | 4 ++-- 14 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0f306b7e15..fe2c3a29b6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -208,7 +208,7 @@ VIR_ENUM_IMPL(virDomainCapsFeature, VIR_DOMAIN_CAPS_FEA= TURE_LAST, "syslog", "wake_alarm") =20 -VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST, +VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_ACTION_LAST, "destroy", "restart", "rename-restart", @@ -18583,14 +18583,14 @@ virDomainDefParseXML(xmlDocPtr xml, if (virDomainEventActionParseXML(ctxt, "on_reboot", "string(./on_reboot[1])", &def->onReboot, - VIR_DOMAIN_LIFECYCLE_RESTART, + VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, virDomainLifecycleTypeFromString) < 0) goto error; =20 if (virDomainEventActionParseXML(ctxt, "on_poweroff", "string(./on_poweroff[1])", &def->onPoweroff, - VIR_DOMAIN_LIFECYCLE_DESTROY, + VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, virDomainLifecycleTypeFromString) < 0) goto error; =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a42efcfa68..4a821fb0f2 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1792,12 +1792,12 @@ typedef enum { } virDomainCapsFeature; =20 typedef enum { - VIR_DOMAIN_LIFECYCLE_DESTROY, - VIR_DOMAIN_LIFECYCLE_RESTART, - VIR_DOMAIN_LIFECYCLE_RESTART_RENAME, - VIR_DOMAIN_LIFECYCLE_PRESERVE, + VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, + VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, + VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME, + VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE, =20 - VIR_DOMAIN_LIFECYCLE_LAST + VIR_DOMAIN_LIFECYCLE_ACTION_LAST } virDomainLifecycleAction; =20 typedef enum { diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 34233a955f..15111af0b7 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -98,19 +98,19 @@ static libxl_action_on_shutdown libxlActionFromVirLifecycle(virDomainLifecycleAction action) { switch (action) { - case VIR_DOMAIN_LIFECYCLE_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: return LIBXL_ACTION_ON_SHUTDOWN_DESTROY; =20 - case VIR_DOMAIN_LIFECYCLE_RESTART: - return LIBXL_ACTION_ON_SHUTDOWN_RESTART; + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: + return LIBXL_ACTION_ON_SHUTDOWN_RESTART; =20 - case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: return LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME; =20 - case VIR_DOMAIN_LIFECYCLE_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE; =20 - case VIR_DOMAIN_LIFECYCLE_LAST: + case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: break; } =20 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 7caa674749..3b260ee15c 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -468,13 +468,13 @@ libxlDomainShutdownThread(void *opaque) VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUTDO= WN); switch ((virDomainLifecycleAction) vm->def->onPoweroff) { - case VIR_DOMAIN_LIFECYCLE_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: goto destroy; - case VIR_DOMAIN_LIFECYCLE_RESTART: - case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: goto restart; - case VIR_DOMAIN_LIFECYCLE_PRESERVE: - case VIR_DOMAIN_LIFECYCLE_LAST: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: goto endjob; } } else if (xl_reason =3D=3D LIBXL_SHUTDOWN_REASON_CRASH) { @@ -508,13 +508,13 @@ libxlDomainShutdownThread(void *opaque) VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUTDO= WN); switch ((virDomainLifecycleAction) vm->def->onReboot) { - case VIR_DOMAIN_LIFECYCLE_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: goto destroy; - case VIR_DOMAIN_LIFECYCLE_RESTART: - case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: goto restart; - case VIR_DOMAIN_LIFECYCLE_PRESERVE: - case VIR_DOMAIN_LIFECYCLE_LAST: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: goto endjob; } } else { diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 5fc6e7cda4..08f82f2580 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -1015,9 +1015,9 @@ lxcParseConfigString(const char *config, vmdef->id =3D -1; virDomainDefSetMemoryTotal(vmdef, 64 * 1024); =20 - vmdef->onReboot =3D VIR_DOMAIN_LIFECYCLE_RESTART; + vmdef->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; vmdef->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; - vmdef->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + vmdef->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; vmdef->virtType =3D VIR_DOMAIN_VIRT_LXC; =20 /* Value not handled by the LXC driver, setting to diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 46f0bdd18c..174385324c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6494,8 +6494,8 @@ qemuBuildPMCommandLine(virCommandPtr cmd, bool allowReboot =3D true; =20 /* Only add -no-reboot option if each event destroys domain */ - if (def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_DESTROY && - def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_DESTROY && + if (def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && + def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && (def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY || def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY))= { allowReboot =3D false; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 36c9fae2b7..d9abe40f29 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1981,8 +1981,8 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, = unsigned int flags) if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; =20 - if (vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_RESTART || - vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_RESTART_RENAME) { + if (vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART || + vm->def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_REN= AME) { isReboot =3D true; agentFlag =3D QEMU_AGENT_SHUTDOWN_REBOOT; VIR_INFO("Domain on_poweroff setting overridden, attempting reboot= "); @@ -2076,8 +2076,8 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) if (!(vm =3D qemuDomObjFromDomain(dom))) goto cleanup; =20 - if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_DESTROY || - vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_PRESERVE) { + if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || + vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) { agentFlag =3D QEMU_AGENT_SHUTDOWN_POWERDOWN; isReboot =3D false; VIR_INFO("Domain on_reboot setting overridden, shutting down"); diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 4896f2afb9..659db96d10 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1833,9 +1833,9 @@ qemuParseCommandLine(virCapsPtr caps, goto error; def->clock.offset =3D VIR_DOMAIN_CLOCK_OFFSET_UTC; =20 - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_RESTART; + def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; - def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; def->virtType =3D VIR_DOMAIN_VIRT_QEMU; if (VIR_STRDUP(def->emulator, progargv[0]) < 0) goto error; @@ -2142,7 +2142,7 @@ qemuParseCommandLine(virCapsPtr caps, } else if (STREQ(arg, "-no-acpi")) { def->features[VIR_DOMAIN_FEATURE_ACPI] =3D VIR_TRISTATE_SWITCH= _ABSENT; } else if (STREQ(arg, "-no-reboot")) { - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; } else if (STREQ(arg, "-no-kvm")) { def->virtType =3D VIR_DOMAIN_VIRT_QEMU; } else if (STREQ(arg, "-enable-kvm")) { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0cb023095b..1898d1c8a3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -496,8 +496,8 @@ qemuProcessHandleReset(qemuMonitorPtr mon ATTRIBUTE_UNU= SED, if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->cap= s) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); =20 - if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_DESTROY || - vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_PRESERVE) { + if (vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || + vm->def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) { =20 if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5742cf4198..8e9e31145f 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1920,22 +1920,22 @@ static int testDomainReboot(virDomainPtr domain, VIR_DOMAIN_SHUTDOWN_USER); =20 switch (privdom->def->onReboot) { - case VIR_DOMAIN_LIFECYCLE_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_SHUTDOWN); break; =20 - case VIR_DOMAIN_LIFECYCLE_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: virDomainObjSetState(privdom, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED); break; =20 - case VIR_DOMAIN_LIFECYCLE_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_SHUTDOWN); break; =20 - case VIR_DOMAIN_LIFECYCLE_RESTART_RENAME: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: virDomainObjSetState(privdom, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED); break; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 8aae635c17..2cb48bb729 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1578,8 +1578,8 @@ virVMXParseConfig(virVMXContext *ctx, } =20 /* def:lifecycle */ - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_RESTART; - def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; + def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; =20 /* def:os */ diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 5f377147c6..c4ffbde9a4 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1887,8 +1887,8 @@ prlsdkLoadDomain(vzDriverPtr driver, =20 def->virtType =3D VIR_DOMAIN_VIRT_VZ; =20 - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_RESTART; - def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; + def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; =20 /* get RAM parameters */ @@ -2591,8 +2591,8 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDo= mainDefPtr def) return -1; } =20 - if (def->onReboot !=3D VIR_DOMAIN_LIFECYCLE_RESTART || - def->onPoweroff !=3D VIR_DOMAIN_LIFECYCLE_DESTROY || + if (def->onReboot !=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART || + def->onPoweroff !=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || def->onCrash !=3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY) { =20 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index 0b16f89a4d..c4bbecc336 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -131,9 +131,9 @@ enum xen_on_normal_exit actionShutdownLibvirt2XenapiEnum(virDomainLifecycleAction action) { enum xen_on_normal_exit num =3D XEN_ON_NORMAL_EXIT_RESTART; - if (action =3D=3D VIR_DOMAIN_LIFECYCLE_DESTROY) + if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) num =3D XEN_ON_NORMAL_EXIT_DESTROY; - else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_RESTART) + else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) num =3D XEN_ON_NORMAL_EXIT_RESTART; return num; } @@ -201,11 +201,11 @@ map2LibvirtBootOrder(char c) virDomainLifecycleAction xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action) { - virDomainLifecycleAction num =3D VIR_DOMAIN_LIFECYCLE_RESTART; + virDomainLifecycleAction num =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; if (action =3D=3D XEN_ON_NORMAL_EXIT_DESTROY) - num =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; else if (action =3D=3D XEN_ON_NORMAL_EXIT_RESTART) - num =3D VIR_DOMAIN_LIFECYCLE_RESTART; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; return num; } =20 diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index fefa61ac23..cf62215e54 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1251,7 +1251,7 @@ xenParseSxpr(const struct sexpr *root, goto error; } } else { - def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_DESTROY; + def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; } =20 tmp =3D sexpr_node(root, "domain/on_reboot"); @@ -1262,7 +1262,7 @@ xenParseSxpr(const struct sexpr *root, goto error; } } else { - def->onReboot =3D VIR_DOMAIN_LIFECYCLE_RESTART; + def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; } =20 tmp =3D sexpr_node(root, "domain/on_crash"); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15081520344391018.605465792628; Mon, 16 Oct 2017 04:07:14 -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 6BDF0C04AC62; Mon, 16 Oct 2017 11:07:13 +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 4647E5C8B4; Mon, 16 Oct 2017 11:07:13 +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 0CB0018355DD; Mon, 16 Oct 2017 11:07:13 +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 v9GB6XWu008667 for ; Mon, 16 Oct 2017 07:06:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73EAF5D964; Mon, 16 Oct 2017 11:06:33 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id F08355D961 for ; Mon, 16 Oct 2017 11:06:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6BDF0C04AC62 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:15 +0200 Message-Id: <00865e3a8f35b8026eccaed7df45c6595f6f8eb9.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/14] conf: rename virDomainLifecycleAction enum functions 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.31]); Mon, 16 Oct 2017 11:07:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 10 +++++----- src/conf/domain_conf.h | 2 +- src/libvirt_private.syms | 4 ++-- src/xenconfig/xen_common.c | 8 ++++---- src/xenconfig/xen_sxpr.c | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fe2c3a29b6..39a4c4d80f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -208,7 +208,7 @@ VIR_ENUM_IMPL(virDomainCapsFeature, VIR_DOMAIN_CAPS_FEA= TURE_LAST, "syslog", "wake_alarm") =20 -VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_ACTION_LAST, +VIR_ENUM_IMPL(virDomainLifecycleAction, VIR_DOMAIN_LIFECYCLE_ACTION_LAST, "destroy", "restart", "rename-restart", @@ -18584,14 +18584,14 @@ virDomainDefParseXML(xmlDocPtr xml, "string(./on_reboot[1])", &def->onReboot, VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, - virDomainLifecycleTypeFromString) < 0) + virDomainLifecycleActionTypeFromStrin= g) < 0) goto error; =20 if (virDomainEventActionParseXML(ctxt, "on_poweroff", "string(./on_poweroff[1])", &def->onPoweroff, VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, - virDomainLifecycleTypeFromString) < 0) + virDomainLifecycleActionTypeFromStrin= g) < 0) goto error; =20 if (virDomainEventActionParseXML(ctxt, "on_crash", @@ -25862,11 +25862,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, =20 if (virDomainEventActionDefFormat(buf, def->onPoweroff, "on_poweroff", - virDomainLifecycleTypeToString) < 0) + virDomainLifecycleActionTypeToString= ) < 0) goto error; if (virDomainEventActionDefFormat(buf, def->onReboot, "on_reboot", - virDomainLifecycleTypeToString) < 0) + virDomainLifecycleActionTypeToString= ) < 0) goto error; if (virDomainEventActionDefFormat(buf, def->onCrash, "on_crash", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4a821fb0f2..a284a40f80 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3211,7 +3211,7 @@ VIR_ENUM_DECL(virDomainBoot) VIR_ENUM_DECL(virDomainFeature) VIR_ENUM_DECL(virDomainCapabilitiesPolicy) VIR_ENUM_DECL(virDomainCapsFeature) -VIR_ENUM_DECL(virDomainLifecycle) +VIR_ENUM_DECL(virDomainLifecycleAction) VIR_ENUM_DECL(virDomainLifecycleCrash) VIR_ENUM_DECL(virDomainDevice) VIR_ENUM_DECL(virDomainDeviceAddress) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4c56f17e29..1fef62a0cb 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -400,10 +400,10 @@ virDomainLeaseInsertPreAlloc; virDomainLeaseInsertPreAlloced; virDomainLeaseRemove; virDomainLeaseRemoveAt; +virDomainLifecycleActionTypeFromString; +virDomainLifecycleActionTypeToString; virDomainLifecycleCrashTypeFromString; virDomainLifecycleCrashTypeToString; -virDomainLifecycleTypeFromString; -virDomainLifecycleTypeToString; virDomainLoaderDefFree; virDomainLoaderTypeFromString; virDomainLoaderTypeToString; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 6d7dc2cde4..a3b82c178e 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -361,7 +361,7 @@ xenParseEventsActions(virConfPtr conf, virDomainDefPtr = def) if (xenConfigGetString(conf, "on_poweroff", &str, "destroy") < 0) return -1; =20 - if ((def->onPoweroff =3D virDomainLifecycleTypeFromString(str)) < 0) { + if ((def->onPoweroff =3D virDomainLifecycleActionTypeFromString(str)) = < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected value %s for on_poweroff"), str); return -1; @@ -370,7 +370,7 @@ xenParseEventsActions(virConfPtr conf, virDomainDefPtr = def) if (xenConfigGetString(conf, "on_reboot", &str, "restart") < 0) return -1; =20 - if ((def->onReboot =3D virDomainLifecycleTypeFromString(str)) < 0) { + if ((def->onReboot =3D virDomainLifecycleActionTypeFromString(str)) < = 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected value %s for on_reboot"), str); return -1; @@ -1449,7 +1449,7 @@ xenFormatEventActions(virConfPtr conf, virDomainDefPt= r def) { const char *lifecycle =3D NULL; =20 - if (!(lifecycle =3D virDomainLifecycleTypeToString(def->onPoweroff))) { + if (!(lifecycle =3D virDomainLifecycleActionTypeToString(def->onPowero= ff))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle action %d"), def->onPowerof= f); return -1; @@ -1458,7 +1458,7 @@ xenFormatEventActions(virConfPtr conf, virDomainDefPt= r def) return -1; =20 =20 - if (!(lifecycle =3D virDomainLifecycleTypeToString(def->onReboot))) { + if (!(lifecycle =3D virDomainLifecycleActionTypeToString(def->onReboot= ))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle action %d"), def->onReboot); return -1; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index cf62215e54..d26026fed2 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1245,7 +1245,7 @@ xenParseSxpr(const struct sexpr *root, =20 tmp =3D sexpr_node(root, "domain/on_poweroff"); if (tmp !=3D NULL) { - if ((def->onPoweroff =3D virDomainLifecycleTypeFromString(tmp)) < = 0) { + if ((def->onPoweroff =3D virDomainLifecycleActionTypeFromString(tm= p)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown lifecycle type %s"), tmp); goto error; @@ -1256,7 +1256,7 @@ xenParseSxpr(const struct sexpr *root, =20 tmp =3D sexpr_node(root, "domain/on_reboot"); if (tmp !=3D NULL) { - if ((def->onReboot =3D virDomainLifecycleTypeFromString(tmp)) < 0)= { + if ((def->onReboot =3D virDomainLifecycleActionTypeFromString(tmp)= ) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown lifecycle type %s"), tmp); goto error; @@ -2214,14 +2214,14 @@ xenFormatSxpr(virConnectPtr conn, virDomainDefPtr d= ef) virBufferEscapeSexpr(&buf, "(bootloader_args '%s')", def->os.b= ootloaderArgs); } =20 - if (!(tmp =3D virDomainLifecycleTypeToString(def->onPoweroff))) { + if (!(tmp =3D virDomainLifecycleActionTypeToString(def->onPoweroff))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle value %d"), def->onPoweroff= ); goto error; } virBufferAsprintf(&buf, "(on_poweroff '%s')", tmp); =20 - if (!(tmp =3D virDomainLifecycleTypeToString(def->onReboot))) { + if (!(tmp =3D virDomainLifecycleActionTypeToString(def->onReboot))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle value %d"), def->onReboot); goto error; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152037223707.434240711207; Mon, 16 Oct 2017 04:07:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 205E2267CA; Mon, 16 Oct 2017 11:07:16 +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 F3EA85D974; Mon, 16 Oct 2017 11:07:15 +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 BE5DB410B3; Mon, 16 Oct 2017 11:07:15 +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 v9GB6YAR008672 for ; Mon, 16 Oct 2017 07:06:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4548F5D965; Mon, 16 Oct 2017 11:06:34 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1BCC5D961 for ; Mon, 16 Oct 2017 11:06:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 205E2267CA Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:16 +0200 Message-Id: <37916771de5558682f5090f698a651c894b96a13.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/14] conf: introduce virDomainLifecycle enum to list all lifecycle types 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 16 Oct 2017 11:07:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 5 +++++ src/conf/domain_conf.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 39a4c4d80f..e9d7f8911e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -208,6 +208,11 @@ VIR_ENUM_IMPL(virDomainCapsFeature, VIR_DOMAIN_CAPS_FE= ATURE_LAST, "syslog", "wake_alarm") =20 +VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST, + "poweroff", + "reboot", + "crash") + VIR_ENUM_IMPL(virDomainLifecycleAction, VIR_DOMAIN_LIFECYCLE_ACTION_LAST, "destroy", "restart", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a284a40f80..bc03c6ec17 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1792,6 +1792,14 @@ typedef enum { } virDomainCapsFeature; =20 typedef enum { + VIR_DOMAIN_LIFECYCLE_POWEROFF, + VIR_DOMAIN_LIFECYCLE_REBOOT, + VIR_DOMAIN_LIFECYCLE_CRASH, + + VIR_DOMAIN_LIFECYCLE_LAST +} virDomainLifecycle; + +typedef enum { VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME, @@ -3211,6 +3219,7 @@ VIR_ENUM_DECL(virDomainBoot) VIR_ENUM_DECL(virDomainFeature) VIR_ENUM_DECL(virDomainCapabilitiesPolicy) VIR_ENUM_DECL(virDomainCapsFeature) +VIR_ENUM_DECL(virDomainLifecycle) VIR_ENUM_DECL(virDomainLifecycleAction) VIR_ENUM_DECL(virDomainLifecycleCrash) VIR_ENUM_DECL(virDomainDevice) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152022841226.64213104870726; Mon, 16 Oct 2017 04:07:02 -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 102734ACA5; Mon, 16 Oct 2017 11:07:01 +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 D94F35C893; Mon, 16 Oct 2017 11:07:00 +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 7D9AF3FAED; Mon, 16 Oct 2017 11:07:00 +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 v9GB6ZHC008677 for ; Mon, 16 Oct 2017 07:06:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E8585D964; Mon, 16 Oct 2017 11:06:35 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92F665D961 for ; Mon, 16 Oct 2017 11:06:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 102734ACA5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:17 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/14] conf: merge virDomainLifecycleCrashAction with virDomainLifecycleAction 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.38]); Mon, 16 Oct 2017 11:07:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is no need to have two different enums where one has the same values as the other one with some additions. Currently for on_poweroff and on_reboot we allow only subset of actions that are allowed for on_crash. This was covered in parse time using two different enums. Now to make sure that we don't allow setting actions that are not supported we need to check it while validating domain config. Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 69 +++++++++++++++++++++++++++++++++++++--= ---- src/conf/domain_conf.h | 14 ++------- src/libvirt_private.syms | 2 -- src/libxl/libxl_conf.c | 33 +++------------------ src/libxl/libxl_domain.c | 20 ++++++++----- src/lxc/lxc_native.c | 2 +- src/qemu/qemu_command.c | 4 +-- src/qemu/qemu_driver.c | 10 +++---- src/qemu/qemu_parse_command.c | 2 +- src/vmx/vmx.c | 2 +- src/vz/vz_sdk.c | 4 +-- src/xenapi/xenapi_utils.c | 30 +++++++++---------- src/xenapi/xenapi_utils.h | 4 +-- src/xenconfig/xen_common.c | 4 +-- src/xenconfig/xen_sxpr.c | 6 ++-- 15 files changed, 112 insertions(+), 94 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e9d7f8911e..f69bcc2530 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -217,12 +217,6 @@ VIR_ENUM_IMPL(virDomainLifecycleAction, VIR_DOMAIN_LIF= ECYCLE_ACTION_LAST, "destroy", "restart", "rename-restart", - "preserve") - -VIR_ENUM_IMPL(virDomainLifecycleCrash, VIR_DOMAIN_LIFECYCLE_CRASH_LAST, - "destroy", - "restart", - "rename-restart", "preserve", "coredump-destroy", "coredump-restart") @@ -5618,6 +5612,60 @@ virDomainDefCheckDuplicateDriveAddresses(const virDo= mainDef *def) } =20 =20 +static bool +virDomainDefLifecycleActionAllowed(virDomainLifecycle type, + virDomainLifecycleAction action) +{ + switch (type) { + case VIR_DOMAIN_LIFECYCLE_POWEROFF: + case VIR_DOMAIN_LIFECYCLE_REBOOT: + switch (action) { + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: + return true; + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: + break; + } + break; + case VIR_DOMAIN_LIFECYCLE_CRASH: + case VIR_DOMAIN_LIFECYCLE_LAST: + return true; + } + + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Lifecycle event '%s' doesn't support '%s' action"), + virDomainLifecycleTypeToString(type), + virDomainLifecycleActionTypeToString(action)); + return false; +} + + +static int +virDomainDefLifecycleActionValidate(const virDomainDef *def) +{ + if (!virDomainDefLifecycleActionAllowed(VIR_DOMAIN_LIFECYCLE_POWEROFF, + def->onPoweroff)) { + return -1; + } + + if (!virDomainDefLifecycleActionAllowed(VIR_DOMAIN_LIFECYCLE_REBOOT, + def->onReboot)) { + return -1; + } + + if (!virDomainDefLifecycleActionAllowed(VIR_DOMAIN_LIFECYCLE_CRASH, + def->onCrash)) { + return -1; + } + + return 0; +} + + static int virDomainDefValidateInternal(const virDomainDef *def) { @@ -5648,6 +5696,9 @@ virDomainDefValidateInternal(const virDomainDef *def) return -1; } =20 + if (virDomainDefLifecycleActionValidate(def) < 0) + return -1; + return 0; } =20 @@ -18602,8 +18653,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (virDomainEventActionParseXML(ctxt, "on_crash", "string(./on_crash[1])", &def->onCrash, - VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY, - virDomainLifecycleCrashTypeFromString= ) < 0) + VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, + virDomainLifecycleActionTypeFromStrin= g) < 0) goto error; =20 if (virDomainEventActionParseXML(ctxt, "on_lockfailure", @@ -25875,7 +25926,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, goto error; if (virDomainEventActionDefFormat(buf, def->onCrash, "on_crash", - virDomainLifecycleCrashTypeToString)= < 0) + virDomainLifecycleActionTypeToString= ) < 0) goto error; if (def->onLockFailure !=3D VIR_DOMAIN_LOCK_FAILURE_DEFAULT && virDomainEventActionDefFormat(buf, def->onLockFailure, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bc03c6ec17..38b966f6de 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1804,22 +1804,13 @@ typedef enum { VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME, VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE, + VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY, + VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART, =20 VIR_DOMAIN_LIFECYCLE_ACTION_LAST } virDomainLifecycleAction; =20 typedef enum { - VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY, - VIR_DOMAIN_LIFECYCLE_CRASH_RESTART, - VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME, - VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE, - VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY, - VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART, - - VIR_DOMAIN_LIFECYCLE_CRASH_LAST -} virDomainLifecycleCrashAction; - -typedef enum { VIR_DOMAIN_LOCK_FAILURE_DEFAULT, VIR_DOMAIN_LOCK_FAILURE_POWEROFF, VIR_DOMAIN_LOCK_FAILURE_RESTART, @@ -3221,7 +3212,6 @@ VIR_ENUM_DECL(virDomainCapabilitiesPolicy) VIR_ENUM_DECL(virDomainCapsFeature) VIR_ENUM_DECL(virDomainLifecycle) VIR_ENUM_DECL(virDomainLifecycleAction) -VIR_ENUM_DECL(virDomainLifecycleCrash) VIR_ENUM_DECL(virDomainDevice) VIR_ENUM_DECL(virDomainDeviceAddress) VIR_ENUM_DECL(virDomainDiskDevice) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1fef62a0cb..4cd328eded 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -402,8 +402,6 @@ virDomainLeaseRemove; virDomainLeaseRemoveAt; virDomainLifecycleActionTypeFromString; virDomainLifecycleActionTypeToString; -virDomainLifecycleCrashTypeFromString; -virDomainLifecycleCrashTypeToString; virDomainLoaderDefFree; virDomainLoaderTypeFromString; virDomainLoaderTypeToString; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 15111af0b7..ecbabfc797 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -110,38 +110,13 @@ libxlActionFromVirLifecycle(virDomainLifecycleAction = action) case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE; =20 - case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: - break; - } - - return 0; -} - - -static libxl_action_on_shutdown -libxlActionFromVirLifecycleCrash(virDomainLifecycleCrashAction action) -{ - - switch (action) { - case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: - return LIBXL_ACTION_ON_SHUTDOWN_DESTROY; - - case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART: - return LIBXL_ACTION_ON_SHUTDOWN_RESTART; - - case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME: - return LIBXL_ACTION_ON_SHUTDOWN_RESTART_RENAME; - - case VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE: - return LIBXL_ACTION_ON_SHUTDOWN_PRESERVE; - - case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: return LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_DESTROY; =20 - case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: return LIBXL_ACTION_ON_SHUTDOWN_COREDUMP_RESTART; =20 - case VIR_DOMAIN_LIFECYCLE_CRASH_LAST: + case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: break; } =20 @@ -2247,7 +2222,7 @@ libxlBuildDomainConfig(virPortAllocatorPtr graphicspo= rts, =20 d_config->on_reboot =3D libxlActionFromVirLifecycle(def->onReboot); d_config->on_poweroff =3D libxlActionFromVirLifecycle(def->onPoweroff); - d_config->on_crash =3D libxlActionFromVirLifecycleCrash(def->onCrash); + d_config->on_crash =3D libxlActionFromVirLifecycle(def->onCrash); =20 return 0; } diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 3b260ee15c..09bfc88f54 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -474,6 +474,8 @@ libxlDomainShutdownThread(void *opaque) case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: goto restart; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: goto endjob; } @@ -484,19 +486,19 @@ libxlDomainShutdownThread(void *opaque) dom_event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_CRASHE= D); - switch ((virDomainLifecycleCrashAction) vm->def->onCrash) { - case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: + switch ((virDomainLifecycleAction) vm->def->onCrash) { + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: goto destroy; - case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART: - case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: goto restart; - case VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE: - case VIR_DOMAIN_LIFECYCLE_CRASH_LAST: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: goto endjob; - case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: libxlDomainAutoCoreDump(driver, vm); goto destroy; - case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: libxlDomainAutoCoreDump(driver, vm); goto restart; } @@ -514,6 +516,8 @@ libxlDomainShutdownThread(void *opaque) case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: goto restart; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: goto endjob; } diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 08f82f2580..68636dc2a4 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -1016,7 +1016,7 @@ lxcParseConfigString(const char *config, virDomainDefSetMemoryTotal(vmdef, 64 * 1024); =20 vmdef->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; - vmdef->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; + vmdef->onCrash =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; vmdef->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; vmdef->virtType =3D VIR_DOMAIN_VIRT_LXC; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 174385324c..6b6de08e47 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6496,8 +6496,8 @@ qemuBuildPMCommandLine(virCommandPtr cmd, /* Only add -no-reboot option if each event destroys domain */ if (def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && - (def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY || - def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY))= { + (def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || + def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)= ) { allowReboot =3D false; virCommandAddArg(cmd, "-no-reboot"); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d9abe40f29..f7d713ab59 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4238,12 +4238,12 @@ processGuestPanicEvent(virQEMUDriverPtr driver, VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); =20 switch (action) { - case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) goto endjob; ATTRIBUTE_FALLTHROUGH; =20 - case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED, QEMU_ASYNC_JOB_DUMP, 0); event =3D virDomainEventLifecycleNewFromObj(vm, @@ -4255,17 +4255,17 @@ processGuestPanicEvent(virQEMUDriverPtr driver, removeInactive =3D true; break; =20 - case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) goto endjob; ATTRIBUTE_FALLTHROUGH; =20 - case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART: + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: qemuDomainSetFakeReboot(driver, vm, true); qemuProcessShutdownOrReboot(driver, vm); break; =20 - case VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE: + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: break; =20 default: diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 659db96d10..4ef28cdd55 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -1834,7 +1834,7 @@ qemuParseCommandLine(virCapsPtr caps, def->clock.offset =3D VIR_DOMAIN_CLOCK_OFFSET_UTC; =20 def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; - def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; + def->onCrash =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; def->virtType =3D VIR_DOMAIN_VIRT_QEMU; if (VIR_STRDUP(def->emulator, progargv[0]) < 0) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 2cb48bb729..622f22f037 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1580,7 +1580,7 @@ virVMXParseConfig(virVMXContext *ctx, /* def:lifecycle */ def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; - def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; + def->onCrash =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; =20 /* def:os */ def->os.type =3D VIR_DOMAIN_OSTYPE_HVM; diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c4ffbde9a4..28d30f248d 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1889,7 +1889,7 @@ prlsdkLoadDomain(vzDriverPtr driver, =20 def->onReboot =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; def->onPoweroff =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; - def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; + def->onCrash =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; =20 /* get RAM parameters */ pret =3D PrlVmCfg_GetRamSize(sdkdom, &ram); @@ -2593,7 +2593,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDo= mainDefPtr def) =20 if (def->onReboot !=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART || def->onPoweroff !=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || - def->onCrash !=3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY) { + def->onCrash !=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) { =20 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("on_reboot, on_poweroff and on_crash parameters " diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index c4bbecc336..cf5bf66732 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -140,20 +140,20 @@ actionShutdownLibvirt2XenapiEnum(virDomainLifecycleAc= tion action) =20 =20 enum xen_on_crash_behaviour -actionCrashLibvirt2XenapiEnum(virDomainLifecycleCrashAction action) +actionCrashLibvirt2XenapiEnum(virDomainLifecycleAction action) { enum xen_on_crash_behaviour num =3D XEN_ON_CRASH_BEHAVIOUR_RESTART; - if (action =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY) + if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) num =3D XEN_ON_CRASH_BEHAVIOUR_DESTROY; - else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_RESTART) + else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) num =3D XEN_ON_CRASH_BEHAVIOUR_RESTART; - else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE) + else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) num =3D XEN_ON_CRASH_BEHAVIOUR_PRESERVE; - else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME) + else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME) num =3D XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART; - else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY) + else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY) num =3D XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY; - else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART) + else if (action =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART) num =3D XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART; return num; } @@ -210,22 +210,22 @@ xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_n= ormal_exit action) } =20 =20 -virDomainLifecycleCrashAction +virDomainLifecycleAction xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action) { - virDomainLifecycleCrashAction num =3D VIR_DOMAIN_LIFECYCLE_CRASH_RESTA= RT; + virDomainLifecycleAction num =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; if (action =3D=3D XEN_ON_CRASH_BEHAVIOUR_DESTROY) - num =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; else if (action =3D=3D XEN_ON_CRASH_BEHAVIOUR_RESTART) - num =3D VIR_DOMAIN_LIFECYCLE_CRASH_RESTART; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART; else if (action =3D=3D XEN_ON_CRASH_BEHAVIOUR_PRESERVE) - num =3D VIR_DOMAIN_LIFECYCLE_CRASH_PRESERVE; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE; else if (action =3D=3D XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART) - num =3D VIR_DOMAIN_LIFECYCLE_CRASH_RESTART_RENAME; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME; else if (action =3D=3D XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_DESTROY) - num =3D VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY; else if (action =3D=3D XEN_ON_CRASH_BEHAVIOUR_COREDUMP_AND_RESTART) - num =3D VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART; + num =3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART; return num; } =20 diff --git a/src/xenapi/xenapi_utils.h b/src/xenapi/xenapi_utils.h index 26e1ac29c5..72c42d11ea 100644 --- a/src/xenapi/xenapi_utils.h +++ b/src/xenapi/xenapi_utils.h @@ -46,7 +46,7 @@ enum xen_on_normal_exit actionShutdownLibvirt2XenapiEnum(virDomainLifecycleAction action); =20 enum xen_on_crash_behaviour -actionCrashLibvirt2XenapiEnum(virDomainLifecycleCrashAction action); +actionCrashLibvirt2XenapiEnum(virDomainLifecycleAction action); =20 char * createXenAPIBootOrderString(int nboot, int *bootDevs); @@ -56,7 +56,7 @@ virDomainBootOrder map2LibvirtBootOrder(char c); virDomainLifecycleAction xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action); =20 -virDomainLifecycleCrashAction +virDomainLifecycleAction xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action); =20 void getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen); diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index a3b82c178e..8fc24b24eb 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -379,7 +379,7 @@ xenParseEventsActions(virConfPtr conf, virDomainDefPtr = def) if (xenConfigGetString(conf, "on_crash", &str, "restart") < 0) return -1; =20 - if ((def->onCrash =3D virDomainLifecycleCrashTypeFromString(str)) < 0)= { + if ((def->onCrash =3D virDomainLifecycleActionTypeFromString(str)) < 0= ) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected value %s for on_crash"), str); return -1; @@ -1467,7 +1467,7 @@ xenFormatEventActions(virConfPtr conf, virDomainDefPt= r def) return -1; =20 =20 - if (!(lifecycle =3D virDomainLifecycleCrashTypeToString(def->onCrash))= ) { + if (!(lifecycle =3D virDomainLifecycleActionTypeToString(def->onCrash)= )) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle action %d"), def->onCrash); return -1; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index d26026fed2..0946804420 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1267,13 +1267,13 @@ xenParseSxpr(const struct sexpr *root, =20 tmp =3D sexpr_node(root, "domain/on_crash"); if (tmp !=3D NULL) { - if ((def->onCrash =3D virDomainLifecycleCrashTypeFromString(tmp)) = < 0) { + if ((def->onCrash =3D virDomainLifecycleActionTypeFromString(tmp))= < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown lifecycle type %s"), tmp); goto error; } } else { - def->onCrash =3D VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY; + def->onCrash =3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY; } =20 if (hvm) { @@ -2228,7 +2228,7 @@ xenFormatSxpr(virConnectPtr conn, virDomainDefPtr def) } virBufferAsprintf(&buf, "(on_reboot '%s')", tmp); =20 - if (!(tmp =3D virDomainLifecycleCrashTypeToString(def->onCrash))) { + if (!(tmp =3D virDomainLifecycleActionTypeToString(def->onCrash))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected lifecycle value %d"), def->onCrash); goto error; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152049506884.6879388114127; Mon, 16 Oct 2017 04:07:29 -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 8CAC1356EA; Mon, 16 Oct 2017 11:07:28 +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 686FB18F14; Mon, 16 Oct 2017 11:07:28 +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 3C4BA410B7; Mon, 16 Oct 2017 11:07:18 +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 v9GB6aT1008685 for ; Mon, 16 Oct 2017 07:06:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 120AB5D964; Mon, 16 Oct 2017 11:06:36 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BB325D961 for ; Mon, 16 Oct 2017 11:06:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8CAC1356EA Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:18 +0200 Message-Id: <80daa519b46f77c60d5f85bcb3745062c19a9562.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/14] qemu: pass virDomainObjPtr to qemuBuildCommandLine 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.30]); Mon, 16 Oct 2017 11:07:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract the required data inside a function instead of passing it all as arguments. Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 18 ++++++++++-------- src/qemu/qemu_command.h | 11 ++--------- src/qemu/qemu_process.c | 19 ++++--------------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6b6de08e47..935b05226d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9947,26 +9947,28 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr drive= r, virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virDomainDefPtr def, - virDomainChrSourceDefPtr monitor_chr, - bool monitor_json, - virQEMUCapsPtr qemuCaps, + virDomainObjPtr vm, const char *migrateURI, virDomainSnapshotObjPtr snapshot, virNetDevVPortProfileOp vmop, bool standalone, bool enableFips, - virBitmapPtr nodeset, size_t *nnicindexes, - int **nicindexes, - const char *domainLibDir, - bool chardevStdioLogd) + int **nicindexes) { size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; virCommandPtr cmd =3D NULL; virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); unsigned int bootHostdevNet =3D 0; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virDomainDefPtr def =3D vm->def; + virDomainChrSourceDefPtr monitor_chr =3D priv->monConfig; + bool monitor_json =3D priv->monJSON; + virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; + virBitmapPtr nodeset =3D priv->autoNodeset; + const char *domainLibDir =3D priv->libDir; + bool chardevStdioLogd =3D priv->chardevStdioLogd; =20 VIR_DEBUG("driver=3D%p def=3D%p mon=3D%p json=3D%d " "qemuCaps=3D%p migrateURI=3D%s snapshot=3D%p vmop=3D%d", diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 94e4592ccd..e1ddc43d62 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -45,21 +45,14 @@ VIR_ENUM_DECL(qemuVideo) =20 virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virDomainDefPtr def, - virDomainChrSourceDefPtr monitor_chr, - bool monitor_json, - virQEMUCapsPtr qemuCaps, + virDomainObjPtr vm, const char *migrateURI, virDomainSnapshotObjPtr snapshot, virNetDevVPortProfileOp vmop, bool standalone, bool enableFips, - virBitmapPtr nodeset, size_t *nnicindexes, - int **nicindexes, - const char *domainLibDir, - bool chardevStdioLogd) - ATTRIBUTE_NONNULL(15); + int **nicindexes); =20 =20 /* Generate the object properties for a secret */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1898d1c8a3..11914a72f3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5650,16 +5650,12 @@ qemuProcessLaunch(virConnectPtr conn, VIR_DEBUG("Building emulator command line"); if (!(cmd =3D qemuBuildCommandLine(driver, qemuDomainLogContextGetManager(logCtx= t), - vm->def, priv->monConfig, - priv->monJSON, priv->qemuCaps, + vm, incoming ? incoming->launchURI : NULL, snapshot, vmop, false, qemuCheckFips(), - priv->autoNodeset, - &nnicindexes, &nicindexes, - priv->libDir, - priv->chardevStdioLogd))) + &nnicindexes, &nicindexes))) goto cleanup; =20 if (incoming && incoming->fd !=3D -1) @@ -6086,7 +6082,6 @@ qemuProcessCreatePretendCmd(virConnectPtr conn, bool standalone, unsigned int flags) { - qemuDomainObjPrivatePtr priv =3D vm->privateData; virCommandPtr cmd =3D NULL; =20 virCheckFlagsGoto(VIR_QEMU_PROCESS_START_COLD | @@ -6106,20 +6101,14 @@ qemuProcessCreatePretendCmd(virConnectPtr conn, VIR_DEBUG("Building emulator command line"); cmd =3D qemuBuildCommandLine(driver, NULL, - vm->def, - priv->monConfig, - priv->monJSON, - priv->qemuCaps, + vm, migrateURI, NULL, VIR_NETDEV_VPORT_PROFILE_OP_NO_OP, standalone, enableFips, - priv->autoNodeset, - NULL, NULL, - priv->libDir, - priv->chardevStdioLogd); + NULL); =20 cleanup: return cmd; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15081520269641011.9248660727709; Mon, 16 Oct 2017 04:07:06 -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 9093580473; Mon, 16 Oct 2017 11:07:05 +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 65A495C7A2; Mon, 16 Oct 2017 11:07:05 +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 2DBA13FAEE; Mon, 16 Oct 2017 11:07:05 +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 v9GB6aLj008702 for ; Mon, 16 Oct 2017 07:06:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6D0D5D964; Mon, 16 Oct 2017 11:06:36 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E4665D965 for ; Mon, 16 Oct 2017 11:06:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9093580473 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:19 +0200 Message-Id: <3579cfa7acc3767fec7aeb5fcfb3961478feccc3.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/14] qemu: pass priv data to qemuBuildMonitorCommandLine 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.28]); Mon, 16 Oct 2017 11:07:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 935b05226d..fa70d15c43 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5609,20 +5609,17 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logMan= ager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, - virDomainChrSourceDefPtr monitor_chr, - bool monitor_json, - bool chardevStdioLogd) + qemuDomainObjPrivatePtr priv) { char *chrdev; =20 - if (!monitor_chr) + if (!priv->monConfig) return 0; =20 if (!(chrdev =3D qemuBuildChrChardevStr(logManager, cmd, cfg, def, - monitor_chr, "monitor", - qemuCaps, true, - chardevStdioLogd))) + priv->monConfig, "monitor", + priv->qemuCaps, true, + priv->chardevStdioLogd))) return -1; virCommandAddArg(cmd, "-chardev"); virCommandAddArg(cmd, chrdev); @@ -5631,7 +5628,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManag= er, virCommandAddArg(cmd, "-mon"); virCommandAddArgFormat(cmd, "chardev=3Dcharmonitor,id=3Dmonitor,mode=3D%s", - monitor_json ? "control" : "readline"); + priv->monJSON ? "control" : "readline"); =20 return 0; } @@ -9963,7 +9960,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, unsigned int bootHostdevNet =3D 0; qemuDomainObjPrivatePtr priv =3D vm->privateData; virDomainDefPtr def =3D vm->def; - virDomainChrSourceDefPtr monitor_chr =3D priv->monConfig; bool monitor_json =3D priv->monJSON; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; virBitmapPtr nodeset =3D priv->autoNodeset; @@ -9972,7 +9968,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, =20 VIR_DEBUG("driver=3D%p def=3D%p mon=3D%p json=3D%d " "qemuCaps=3D%p migrateURI=3D%s snapshot=3D%p vmop=3D%d", - driver, def, monitor_chr, monitor_json, + driver, def, priv->monConfig, monitor_json, qemuCaps, migrateURI, snapshot, vmop); =20 if (qemuBuildCommandLineValidate(driver, def) < 0) @@ -10066,10 +10062,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSgaCommandLine(cmd, def, qemuCaps) < 0) goto error; =20 - if (qemuBuildMonitorCommandLine(logManager, cmd, cfg, def, - qemuCaps, monitor_chr, - monitor_json, - chardevStdioLogd) < 0) + if (qemuBuildMonitorCommandLine(logManager, cmd, cfg, def, priv) < 0) goto error; =20 if (qemuBuildClockCommandLine(cmd, def, qemuCaps) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152031353514.2582633480705; Mon, 16 Oct 2017 04:07:11 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2D713C04AC4D; Mon, 16 Oct 2017 11:07: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 0437A62923; Mon, 16 Oct 2017 11:07: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 BFDDB18355D9; Mon, 16 Oct 2017 11:07:07 +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 v9GB6b2b008709 for ; Mon, 16 Oct 2017 07:06:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9C165D964; Mon, 16 Oct 2017 11:06:37 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 308215D961 for ; Mon, 16 Oct 2017 11:06:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D713C04AC4D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:20 +0200 Message-Id: <652317a362611e905c2709217e8c90ac1a5b331d.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/14] qemu: pass priv data to qemuBuildPMCommandLine 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 16 Oct 2017 11:07:08 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fa70d15c43..da59a1fd63 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6485,10 +6485,10 @@ qemuBuildClockCommandLine(virCommandPtr cmd, static int qemuBuildPMCommandLine(virCommandPtr cmd, const virDomainDef *def, - virQEMUCapsPtr qemuCaps, - bool monitor_json) + qemuDomainObjPrivatePtr priv) { bool allowReboot =3D true; + virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; =20 /* Only add -no-reboot option if each event destroys domain */ if (def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && @@ -6503,7 +6503,7 @@ qemuBuildPMCommandLine(virCommandPtr cmd, * when QEMU stops. If we use no-shutdown, then we can * watch for this event and do a soft/warm reboot. */ - if (monitor_json && allowReboot && + if (priv->monJSON && allowReboot && virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) { virCommandAddArg(cmd, "-no-shutdown"); } @@ -9960,7 +9960,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, unsigned int bootHostdevNet =3D 0; qemuDomainObjPrivatePtr priv =3D vm->privateData; virDomainDefPtr def =3D vm->def; - bool monitor_json =3D priv->monJSON; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; virBitmapPtr nodeset =3D priv->autoNodeset; const char *domainLibDir =3D priv->libDir; @@ -9968,7 +9967,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, =20 VIR_DEBUG("driver=3D%p def=3D%p mon=3D%p json=3D%d " "qemuCaps=3D%p migrateURI=3D%s snapshot=3D%p vmop=3D%d", - driver, def, priv->monConfig, monitor_json, + driver, def, priv->monConfig, priv->monJSON, qemuCaps, migrateURI, snapshot, vmop); =20 if (qemuBuildCommandLineValidate(driver, def) < 0) @@ -10068,7 +10067,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildClockCommandLine(cmd, def, qemuCaps) < 0) goto error; =20 - if (qemuBuildPMCommandLine(cmd, def, qemuCaps, monitor_json) < 0) + if (qemuBuildPMCommandLine(cmd, def, priv) < 0) goto error; =20 if (qemuBuildBootCommandLine(cmd, def, qemuCaps) < 0) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150815203192182.50344652396439; Mon, 16 Oct 2017 04:07:11 -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 CA8637E420; Mon, 16 Oct 2017 11:07:10 +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 9AD375C7A4; Mon, 16 Oct 2017 11:07:10 +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 647813FC73; Mon, 16 Oct 2017 11:07:10 +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 v9GB6c36008719 for ; Mon, 16 Oct 2017 07:06:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7D6BA5D964; Mon, 16 Oct 2017 11:06:38 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 036685D961 for ; Mon, 16 Oct 2017 11:06:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CA8637E420 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: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:21 +0200 Message-Id: <000460891a73cf70a67a1cabb14346008f904ca2.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/14] qemu: pass priv data to qemuBuildMasterKeyCommandLine 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.27]); Mon, 16 Oct 2017 11:07:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index da59a1fd63..5441f5e37f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -201,8 +201,7 @@ qemuBuildHasMasterKey(virQEMUCapsPtr qemuCaps) */ static int qemuBuildMasterKeyCommandLine(virCommandPtr cmd, - virQEMUCapsPtr qemuCaps, - const char *domainLibDir) + qemuDomainObjPrivatePtr priv) { int ret =3D -1; char *alias =3D NULL; @@ -213,7 +212,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd, * means the domain won't be able to use a secret master key and is * not a failure. */ - if (!qemuBuildHasMasterKey(qemuCaps)) { + if (!qemuBuildHasMasterKey(priv->qemuCaps)) { VIR_INFO("secret object is not supported by this QEMU binary"); return 0; } @@ -226,7 +225,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd, * than other command line options which do not check for the * existence of socket files before using. */ - if (!(path =3D qemuDomainGetMasterKeyFilePath(domainLibDir))) + if (!(path =3D qemuDomainGetMasterKeyFilePath(priv->libDir))) goto cleanup; =20 virCommandAddArg(cmd, "-object"); @@ -9962,7 +9961,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, virDomainDefPtr def =3D vm->def; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; virBitmapPtr nodeset =3D priv->autoNodeset; - const char *domainLibDir =3D priv->libDir; bool chardevStdioLogd =3D priv->chardevStdioLogd; =20 VIR_DEBUG("driver=3D%p def=3D%p mon=3D%p json=3D%d " @@ -9991,7 +9989,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (!standalone) virCommandAddArg(cmd, "-S"); /* freeze CPU */ =20 - if (qemuBuildMasterKeyCommandLine(cmd, qemuCaps, domainLibDir) < 0) + if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0) goto error; =20 if (enableFips) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152042036507.43595388798394; Mon, 16 Oct 2017 04:07:22 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 143F48765C; Mon, 16 Oct 2017 11:07:21 +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 E767662685; Mon, 16 Oct 2017 11:07:20 +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 AC71718355E1; Mon, 16 Oct 2017 11:07:20 +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 v9GB6dxM008732 for ; Mon, 16 Oct 2017 07:06:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E8D25D964; Mon, 16 Oct 2017 11:06:39 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA7CA5D961 for ; Mon, 16 Oct 2017 11:06:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 143F48765C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:22 +0200 Message-Id: <2c9e2d80e2039f453711cec618245ebf9941acc2.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/14] qemu: pass priv data instead of qemuCaps and autoNodeset 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 16 Oct 2017 11:07:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5441f5e37f..db6cc55495 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3543,10 +3543,9 @@ qemuBuildMemoryBackendStr(virJSONValuePtr *backendPr= ops, =20 static int qemuBuildMemoryCellBackendStr(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, virQEMUDriverConfigPtr cfg, size_t cell, - virBitmapPtr auto_nodeset, + qemuDomainObjPrivatePtr priv, char **backendStr) { virJSONValuePtr props =3D NULL; @@ -3565,8 +3564,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, if (virAsprintf(&alias, "ram-node%zu", cell) < 0) goto cleanup; =20 - if ((rc =3D qemuBuildMemoryBackendStr(&props, &backendType, cfg, qemuC= aps, - def, &mem, auto_nodeset, false)) <= 0) + if ((rc =3D qemuBuildMemoryBackendStr(&props, &backendType, cfg, priv-= >qemuCaps, + def, &mem, priv->autoNodeset, fals= e)) < 0) goto cleanup; =20 if (!(*backendStr =3D virQEMUBuildObjectCommandlineFromJSON(backendTyp= e, @@ -3587,9 +3586,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def, static char * qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem, virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, virQEMUDriverConfigPtr cfg, - virBitmapPtr auto_nodeset) + qemuDomainObjPrivatePtr priv) { virJSONValuePtr props =3D NULL; char *alias =3D NULL; @@ -3605,8 +3603,8 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr m= em, if (virAsprintf(&alias, "mem%s", mem->info.alias) < 0) goto cleanup; =20 - if (qemuBuildMemoryBackendStr(&props, &backendType, cfg, qemuCaps, - def, mem, auto_nodeset, true) < 0) + if (qemuBuildMemoryBackendStr(&props, &backendType, cfg, priv->qemuCap= s, + def, mem, priv->autoNodeset, true) < 0) goto cleanup; =20 ret =3D virQEMUBuildObjectCommandlineFromJSON(backendType, alias, prop= s); @@ -7717,10 +7715,10 @@ static int qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, virDomainDefPtr def, virCommandPtr cmd, - virQEMUCapsPtr qemuCaps, - virBitmapPtr auto_nodeset) + qemuDomainObjPrivatePtr priv) { size_t i; + virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; virBuffer buf =3D VIR_BUFFER_INITIALIZER; char *cpumask =3D NULL, *tmpmask =3D NULL, *next =3D NULL; char **nodeBackends =3D NULL; @@ -7748,7 +7746,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, goto cleanup; } =20 - if (!virDomainNumatuneNodesetIsAvailable(def->numa, auto_nodeset)) + if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset)) goto cleanup; =20 for (i =3D 0; i < def->mem.nhugepages; i++) { @@ -7783,8 +7781,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, for (i =3D 0; i < ncells; i++) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) || virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) { - if ((rc =3D qemuBuildMemoryCellBackendStr(def, qemuCaps, cfg, = i, - auto_nodeset, + if ((rc =3D qemuBuildMemoryCellBackendStr(def, cfg, i, priv, &nodeBackends[i])) < 0) goto cleanup; =20 @@ -7859,8 +7856,7 @@ static int qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd, virQEMUDriverConfigPtr cfg, virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, - virBitmapPtr nodeset) + qemuDomainObjPrivatePtr priv) { size_t i; =20 @@ -7871,7 +7867,7 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd, char *dimmStr; =20 if (!(backStr =3D qemuBuildMemoryDimmBackendStr(def->mems[i], def, - qemuCaps, cfg, nodes= et))) + cfg, priv))) return -1; =20 if (!(dimmStr =3D qemuBuildMemoryDeviceStr(def->mems[i]))) { @@ -9960,7 +9956,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv =3D vm->privateData; virDomainDefPtr def =3D vm->def; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; - virBitmapPtr nodeset =3D priv->autoNodeset; bool chardevStdioLogd =3D priv->chardevStdioLogd; =20 VIR_DEBUG("driver=3D%p def=3D%p mon=3D%p json=3D%d " @@ -10016,10 +10011,10 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, goto error; =20 if (virDomainNumaGetNodeCount(def->numa) && - qemuBuildNumaArgStr(cfg, def, cmd, qemuCaps, nodeset) < 0) + qemuBuildNumaArgStr(cfg, def, cmd, priv) < 0) goto error; =20 - if (qemuBuildMemoryDeviceCommandLine(cmd, cfg, def, qemuCaps, nodeset)= < 0) + if (qemuBuildMemoryDeviceCommandLine(cmd, cfg, def, priv) < 0) goto error; =20 virUUIDFormat(def->uuid, uuid); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152136045373.9904513939998; Mon, 16 Oct 2017 04:08:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0696A3680B; Mon, 16 Oct 2017 11:08:55 +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 D769160618; Mon, 16 Oct 2017 11:08:54 +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 9A27018355DB; Mon, 16 Oct 2017 11:08:54 +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 v9GB6eid008744 for ; Mon, 16 Oct 2017 07:06:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 200F95D964; Mon, 16 Oct 2017 11:06:40 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C5A85D961 for ; Mon, 16 Oct 2017 11:06:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0696A3680B Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:23 +0200 Message-Id: <7b9d0d4823d05967e5a876149861f11b0dd1ee87.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/14] lib: introduce virDomainSetLifecycleAction() 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 16 Oct 2017 11:08:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- docs/formatdomain.html.in | 6 +++++ include/libvirt/libvirt-domain.h | 28 ++++++++++++++++++++ src/conf/domain_conf.h | 19 -------------- src/driver-hypervisor.h | 7 +++++ src/libvirt-domain.c | 56 ++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_public.syms | 5 ++++ src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 14 +++++++++- 8 files changed, 116 insertions(+), 20 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b93ace7cba..cb19a547fe 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1623,6 +1623,12 @@ =20

+ The lifecycle events can be configured via + virDomainSetLifecycleAction() API + since 3.9.0 (QEMU only). +

+ +

The on_lockfailure element (since 1.0.0) may be used to configure what action should be taken when a lock manager loses resource locks. The following diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 9fb94a9837..4048acf38a 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -4728,4 +4728,32 @@ int virDomainSetBlockThreshold(virDomainPtr domain, unsigned long long threshold, unsigned int flags); =20 +typedef enum { + VIR_DOMAIN_LIFECYCLE_POWEROFF =3D 0, + VIR_DOMAIN_LIFECYCLE_REBOOT =3D 1, + VIR_DOMAIN_LIFECYCLE_CRASH =3D 2, + +# ifdef VIR_ENUM_SENTINELS + VIR_DOMAIN_LIFECYCLE_LAST +# endif +} virDomainLifecycle; + +typedef enum { + VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY =3D 0, + VIR_DOMAIN_LIFECYCLE_ACTION_RESTART =3D 1, + VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME =3D 2, + VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE =3D 3, + VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY =3D 4, + VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART =3D 5, + +# ifdef VIR_ENUM_SENTINELS + VIR_DOMAIN_LIFECYCLE_ACTION_LAST +# endif +} virDomainLifecycleAction; + +int virDomainSetLifecycleAction(virDomainPtr domain, + unsigned int type, + unsigned int action, + unsigned int flags); + #endif /* __VIR_LIBVIRT_DOMAIN_H__ */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 38b966f6de..8240433611 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1792,25 +1792,6 @@ typedef enum { } virDomainCapsFeature; =20 typedef enum { - VIR_DOMAIN_LIFECYCLE_POWEROFF, - VIR_DOMAIN_LIFECYCLE_REBOOT, - VIR_DOMAIN_LIFECYCLE_CRASH, - - VIR_DOMAIN_LIFECYCLE_LAST -} virDomainLifecycle; - -typedef enum { - VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, - VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, - VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME, - VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE, - VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY, - VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART, - - VIR_DOMAIN_LIFECYCLE_ACTION_LAST -} virDomainLifecycleAction; - -typedef enum { VIR_DOMAIN_LOCK_FAILURE_DEFAULT, VIR_DOMAIN_LOCK_FAILURE_POWEROFF, VIR_DOMAIN_LOCK_FAILURE_RESTART, diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 4de0581c3f..ce0e2b2525 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1277,6 +1277,12 @@ typedef int unsigned long long threshold, unsigned int flags); =20 +typedef int +(*virDrvDomainSetLifecycleAction)(virDomainPtr domain, + unsigned int type, + unsigned int action, + unsigned int flags); + =20 typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1521,6 +1527,7 @@ struct _virHypervisorDriver { virDrvDomainSetGuestVcpus domainSetGuestVcpus; virDrvDomainSetVcpu domainSetVcpu; virDrvDomainSetBlockThreshold domainSetBlockThreshold; + virDrvDomainSetLifecycleAction domainSetLifecycleAction; }; =20 =20 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index fc2e4ce381..a51d8e3820 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12035,3 +12035,59 @@ virDomainSetBlockThreshold(virDomainPtr domain, virDispatchError(domain->conn); return -1; } + + +/** + * virDomainSetLifecycleAction: + * @domain: pointer to domain object + * @type: the lifecycle type from virDomainLifecycle + * @action: the action type from virDomainLifecycleAction + * @flags: bitwise-OR of virDomainModificationImpact + * + * Changes the actions of lifecycle events for domain represented as + * $action in the domain XML. + * + * Returns 0 on success, -1 on failure. + */ +int virDomainSetLifecycleAction(virDomainPtr domain, + unsigned int type, + unsigned int action, + unsigned int flags) +{ + VIR_DOMAIN_DEBUG(domain, "type=3D'%u' action=3D'%u' flags=3D'0x%x'", + type, action, flags); + + virResetLastError(); + + virCheckDomainReturn(domain, -1); + virCheckReadOnlyGoto(domain->conn->flags, error); + + if (type >=3D VIR_DOMAIN_LIFECYCLE_LAST) { + virReportError(VIR_ERR_INVALID_ARG, + _("invalid lifecycle type '%u'"), type); + goto error; + } + + if (action >=3D VIR_DOMAIN_LIFECYCLE_ACTION_LAST) { + virReportError(VIR_ERR_INVALID_ARG, + _("invalid lifecycle action '%u'"), action); + goto error; + } + + if (domain->conn->driver->domainSetLifecycleAction) { + int ret; + ret =3D domain->conn->driver->domainSetLifecycleAction(domain, + type, + action, + flags); + if (ret < 0) + goto error; + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(domain->conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 4986019431..0efde25a7f 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -774,4 +774,9 @@ LIBVIRT_3.7.0 { virDomainManagedSaveGetXMLDesc; virDomainManagedSaveDefineXML; } LIBVIRT_3.4.0; + +LIBVIRT_3.9.0 { + global: + virDomainSetLifecycleAction; +} LIBVIRT_3.7.0; # .... define new API here using predicted next version number .... diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 00e8086d51..06719bb825 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8497,6 +8497,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainSetGuestVcpus =3D remoteDomainSetGuestVcpus, /* 2.0.0 */ .domainSetVcpu =3D remoteDomainSetVcpu, /* 3.1.0 */ .domainSetBlockThreshold =3D remoteDomainSetBlockThreshold, /* 3.2.0 */ + .domainSetLifecycleAction =3D remoteDomainSetLifecycleAction /* 3.9.0 = */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index e3014f66bc..0aed25220d 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3433,6 +3433,12 @@ struct remote_domain_set_block_threshold_args { unsigned int flags; }; =20 +struct remote_domain_set_lifecycle_action_args { + remote_nonnull_domain dom; + unsigned int type; + unsigned int action; + unsigned int flags; +}; =20 /*----- Protocol. -----*/ =20 @@ -6108,5 +6114,11 @@ enum remote_procedure { * @acl: domain:write * @acl: domain:hibernate */ - REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML =3D 389 + REMOTE_PROC_DOMAIN_MANAGED_SAVE_DEFINE_XML =3D 389, + + /** + * @generate: both + * @acl: domain:write + */ + REMOTE_PROC_DOMAIN_SET_LIFECYCLE_ACTION =3D 390 }; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152051829513.9688052559803; Mon, 16 Oct 2017 04:07:31 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B2D0181E00; Mon, 16 Oct 2017 11:07:30 +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 8B5356292F; Mon, 16 Oct 2017 11:07:30 +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 53C5C5EC67; Mon, 16 Oct 2017 11:07:23 +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 v9GB6eaV008750 for ; Mon, 16 Oct 2017 07:06:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id E7D8C5D965; Mon, 16 Oct 2017 11:06:40 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FFC25D964 for ; Mon, 16 Oct 2017 11:06:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B2D0181E00 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:24 +0200 Message-Id: <7e212467e81b71d5f969edbd7799e03d9e72d157.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/14] virsh: introduce set-lifecycle-action command 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 16 Oct 2017 11:07:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- tools/virsh-domain.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ tools/virsh.pod | 7 ++++ 2 files changed, 109 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a50713d6e4..bdafdf6f5d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -5517,6 +5517,102 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd) } =20 /* + * "set-lifecycle-action" command + */ +static const vshCmdInfo info_setLifecycleAction[] =3D { + {.name =3D "help", + .data =3D N_("change lifecycle actions") + }, + {.name =3D "desc", + .data =3D N_("Change lifecycle actions for the guest domain.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_setLifecycleAction[] =3D { + VIRSH_COMMON_OPT_DOMAIN_FULL, + {.name =3D "type", + .type =3D VSH_OT_STRING, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("lifecycle type to modify") + }, + {.name =3D "action", + .type =3D VSH_OT_STRING, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("lifecycle action to set") + }, + VIRSH_COMMON_OPT_DOMAIN_CONFIG, + VIRSH_COMMON_OPT_DOMAIN_LIVE, + VIRSH_COMMON_OPT_DOMAIN_CURRENT, + {.name =3D NULL} +}; + +VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST, + "poweroff", + "reboot", + "crash") + +VIR_ENUM_IMPL(virDomainLifecycleAction, VIR_DOMAIN_LIFECYCLE_ACTION_LAST, + "destroy", + "restart", + "rename-restart", + "preserve", + "coredump-destroy", + "coredump-restart") + +static bool +cmdSetLifecycleAction(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom; + bool ret =3D true; + bool config =3D vshCommandOptBool(cmd, "config"); + bool live =3D vshCommandOptBool(cmd, "live"); + bool current =3D vshCommandOptBool(cmd, "current"); + const char *typeStr; + const char *actionStr; + unsigned int type; + unsigned int action; + unsigned int flags =3D 0; + int tmpVal; + + VSH_EXCLUSIVE_OPTIONS_VAR(current, live); + VSH_EXCLUSIVE_OPTIONS_VAR(current, config); + + if (config) + flags |=3D VIR_DOMAIN_AFFECT_CONFIG; + if (live) + flags |=3D VIR_DOMAIN_AFFECT_LIVE; + + if (vshCommandOptStringReq(ctl, cmd, "type", &typeStr) < 0 || + vshCommandOptStringReq(ctl, cmd, "action", &actionStr) < 0) { + return false; + } + + if ((tmpVal =3D virDomainLifecycleTypeFromString(typeStr)) < 0) { + return false; + vshError(ctl, _("Invalid lifecycle type '%s'."), typeStr); + } + type =3D tmpVal; + + if ((tmpVal =3D virDomainLifecycleActionTypeFromString(actionStr)) < 0= ) { + vshError(ctl, _("Invalid lifecycle action '%s'."), actionStr); + return false; + } + action =3D tmpVal; + + if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (virDomainSetLifecycleAction(dom, type, action, flags) < 0) { + vshError(ctl, "%s", _("Unable to change lifecycle action.")); + ret =3D false; + } + + virshDomainFree(dom); + return ret; +} + +/* * "set-user-password" command */ static const vshCmdInfo info_set_user_password[] =3D { @@ -14249,6 +14345,12 @@ const vshCmdDef domManagementCmds[] =3D { .info =3D info_screenshot, .flags =3D 0 }, + {.name =3D "set-lifecycle-action", + .handler =3D cmdSetLifecycleAction, + .opts =3D opts_setLifecycleAction, + .info =3D info_setLifecycleAction, + .flags =3D 0 + }, {.name =3D "set-user-password", .handler =3D cmdSetUserPassword, .opts =3D opts_set_user_password, diff --git a/tools/virsh.pod b/tools/virsh.pod index 024d027699..39cb67792a 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2327,6 +2327,13 @@ the value from the host, use the B co= mmand. In order to view the current memory in use and the maximum value allowed to set memory, use the B command. =20 +=3Ditem B I I I +[[I<--config>] [I<--live>] | [I<--current>]] + +Set the lifecycle action for specified lifecycle type. For the list of +lifecycle types and actions and possible combinations see the documentatio= n at +L. + =3Ditem B I I I [I<--encrypted>] =20 Set the password for the I account in the guest domain. --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152047237877.6726814132783; Mon, 16 Oct 2017 04:07:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FD1D81DF0; Mon, 16 Oct 2017 11:07:26 +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 1DAD960636; Mon, 16 Oct 2017 11:07:26 +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 D9FCD18355E3; Mon, 16 Oct 2017 11:07:25 +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 v9GB6feB008764 for ; Mon, 16 Oct 2017 07:06:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id D075C5D965; Mon, 16 Oct 2017 11:06:41 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58D135D964 for ; Mon, 16 Oct 2017 11:06:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FD1D81DF0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:25 +0200 Message-Id: <8a1bcfdff526314123899ba4a09609280c4cadb8.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/14] qemu: move detection whether to use -no-reboot to qemu_domain 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 16 Oct 2017 11:07:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This will be used later on in implementation of new API virDomainSetLifecycleAction(). In order to use it, we need to store the value in status XML to not lose the information if libvirtd is restarted. If some guest was started by old libvirt where it was not possible to change the lifecycle action for running guest, we can safely detect it based on the current actions from the status XML. Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 10 ++-------- src/qemu/qemu_domain.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 1 + src/qemu/qemu_process.c | 30 ++++++++++++++++++++++++++++++ tests/qemuxml2xmltest.c | 3 ++- 5 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index db6cc55495..046a8fc78f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6484,23 +6484,17 @@ qemuBuildPMCommandLine(virCommandPtr cmd, const virDomainDef *def, qemuDomainObjPrivatePtr priv) { - bool allowReboot =3D true; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; =20 /* Only add -no-reboot option if each event destroys domain */ - if (def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && - def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && - (def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || - def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)= ) { - allowReboot =3D false; + if (priv->allowReboot =3D=3D VIR_TRISTATE_BOOL_NO) virCommandAddArg(cmd, "-no-reboot"); - } =20 /* If JSON monitor is enabled, we can receive an event * when QEMU stops. If we use no-shutdown, then we can * watch for this event and do a soft/warm reboot. */ - if (priv->monJSON && allowReboot && + if (priv->monJSON && priv->allowReboot =3D=3D VIR_TRISTATE_BOOL_YES && virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) { virCommandAddArg(cmd, "-no-shutdown"); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ed27a91fa6..2630b73221 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1767,6 +1767,7 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivatePtr= priv) priv->namespaces =3D NULL; =20 priv->reconnectBlockjobs =3D VIR_TRISTATE_BOOL_ABSENT; + priv->allowReboot =3D VIR_TRISTATE_BOOL_ABSENT; } =20 =20 @@ -1876,6 +1877,16 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr = buf, } =20 =20 +static void +qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf, + virTristateBool allowReboot) +{ + virBufferAsprintf(buf, "\n", + virTristateBoolTypeToString(allowReboot)); + +} + + static int qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virDomainObjPtr vm) @@ -1998,6 +2009,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (priv->chardevStdioLogd) virBufferAddLit(buf, "\n"); =20 + qemuDomainObjPrivateXMLFormatAllowReboot(buf, priv->allowReboot); + if (qemuDomainObjPrivateXMLFormatBlockjobs(buf, vm) < 0) return -1; =20 @@ -2109,6 +2122,31 @@ qemuDomainObjPrivateXMLParseBlockjobs(qemuDomainObjP= rivatePtr priv, =20 =20 static int +qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, + virTristateBool *allowReboot) +{ + int ret =3D -1; + int val; + char *valStr; + + if ((valStr =3D virXPathString("string(./allowReboot/@value)", ctxt)))= { + if ((val =3D virTristateBoolTypeFromString(valStr)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("invalid allowReboot value '%s'"), valStr); + goto cleanup; + } + *allowReboot =3D val; + } + + ret =3D 0; + + cleanup: + VIR_FREE(valStr); + return ret; +} + + +static int qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, virDomainObjPtr vm, virDomainDefParserConfigPtr config) @@ -2323,6 +2361,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, priv->chardevStdioLogd =3D virXPathBoolean("boolean(./chardevStdioLogd= )", ctxt) =3D=3D 1; =20 + qemuDomainObjPrivateXMLParseAllowReboot(ctxt, &priv->allowReboot); + if (qemuDomainObjPrivateXMLParseBlockjobs(priv, ctxt) < 0) goto error; =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 00226a3fc8..be4aaa5613 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -261,6 +261,7 @@ struct _qemuDomainObjPrivate { char *lockState; =20 bool fakeReboot; + virTristateBool allowReboot; =20 int jobs_queued; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 11914a72f3..e555ec9c96 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5309,6 +5309,26 @@ qemuProcessPrepareDomainStorage(virConnectPtr conn, } =20 =20 +static void +qemuProcessPrepareAllowReboot(virDomainObjPtr vm) +{ + virDomainDefPtr def =3D vm->def; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + if (priv->allowReboot !=3D VIR_TRISTATE_BOOL_ABSENT) + return; + + if (def->onReboot =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && + def->onPoweroff =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY && + (def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || + def->onCrash =3D=3D VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)= ) { + priv->allowReboot =3D VIR_TRISTATE_BOOL_NO; + } else { + priv->allowReboot =3D VIR_TRISTATE_BOOL_YES; + } +} + + /** * qemuProcessPrepareDomain: * @conn: connection object (for looking up storage volumes) @@ -5365,6 +5385,8 @@ qemuProcessPrepareDomain(virConnectPtr conn, priv->chardevStdioLogd =3D true; } =20 + qemuProcessPrepareAllowReboot(vm); + /* * Normally PCI addresses are assigned in the virDomainCreate * or virDomainDefine methods. We might still need to assign @@ -6618,6 +6640,10 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_U= NUSED, =20 priv->gotShutdown =3D false; =20 + /* Attaching to running QEMU so we need to detect whether it was start= ed + * with -no-reboot. */ + qemuProcessPrepareAllowReboot(vm); + /* * Normally PCI addresses are assigned in the virDomainCreate * or virDomainDefine methods. We might still need to assign @@ -6934,6 +6960,10 @@ qemuProcessReconnect(void *opaque) if (qemuDomainMasterKeyReadFile(priv) < 0) goto error; =20 + /* If we are connecting to a guest started by old libvirt there is no + * allowReboot in status XML and we need to initialize it. */ + qemuProcessPrepareAllowReboot(obj); + VIR_DEBUG("Reconnect monitor to %p '%s'", obj, obj->def->name); =20 /* XXX check PID liveliness & EXE path */ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 14f5b58fe9..2185532a6c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -109,7 +109,8 @@ static const char testStatusXMLPrefixBodyStatic[] =3D "\n" "\n" "\n" -"\n"; +"\n" +"\n"; =20 static const char testStatusXMLSuffix[] =3D "\n"; --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508152056591443.28297944303915; Mon, 16 Oct 2017 04:07:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73AEB7E439; Mon, 16 Oct 2017 11:07: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 4F45F6062A; Mon, 16 Oct 2017 11:07:35 +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 808A762CEF; Mon, 16 Oct 2017 11:07:28 +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 v9GB6gFx008776 for ; Mon, 16 Oct 2017 07:06:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id A28EE5D965; Mon, 16 Oct 2017 11:06:42 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A45C5D964 for ; Mon, 16 Oct 2017 11:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73AEB7E439 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: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:26 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/14] qemu: send allowReboot in migration cookie 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 16 Oct 2017 11:07:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to send allowReboot in the migration cookie to ensure the same behavior of the virDomainSetLifecycleAction() API on the destination. Consider this scenario: 1. On the source the domain is started with: destroy restart destroy 2. User calls an API to set "destroy" for : destroy destroy destroy 3. The guest is migrated to a different host 4a. Without the allowReboot in the migration cookie the QEMU process on destination would be started with -no-reboot which would prevent using the virDomainSetLifecycleAction() API for the rest of the guest lifetime. 4b. With the allowReboot in the migration cookie the QEMU process on destination is started without -no-reboot like it was started on the source host and the virDomainSetLifecycleAction() API continues to work. The following patch adds a QEMU implementation of the virDomainSetLifecycleAction() API and that implementation disallows using the API if all actions are set to "destroy" because we add "-no-reboot" on the QEMU command line. Changing the lifecycle action is in this case pointless because the QEMU process is always terminated. Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_domain.h | 8 ++++++++ src/qemu/qemu_migration.c | 7 ++++++- src/qemu/qemu_migration_cookie.c | 25 ++++++++++++++++++++++++- src/qemu/qemu_migration_cookie.h | 5 +++++ 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2630b73221..d74703fd3e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1877,7 +1877,7 @@ qemuDomainObjPrivateXMLFormatBlockjobs(virBufferPtr b= uf, } =20 =20 -static void +void qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf, virTristateBool allowReboot) { @@ -2121,7 +2121,7 @@ qemuDomainObjPrivateXMLParseBlockjobs(qemuDomainObjPr= ivatePtr priv, } =20 =20 -static int +int qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, virTristateBool *allowReboot) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index be4aaa5613..563438f0cc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -975,4 +975,12 @@ qemuDomainUpdateCPU(virDomainObjPtr vm, char * qemuDomainGetMachineName(virDomainObjPtr vm); =20 +void +qemuDomainObjPrivateXMLFormatAllowReboot(virBufferPtr buf, + virTristateBool allowReboot); + +int +qemuDomainObjPrivateXMLParseAllowReboot(xmlXPathContextPtr ctxt, + virTristateBool *allowReboot); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index dd60071bfd..5b394d3bbc 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2013,6 +2013,8 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver, if (priv->origCPU) cookieFlags |=3D QEMU_MIGRATION_COOKIE_CPU; =20 + cookieFlags |=3D QEMU_MIGRATION_COOKIE_ALLOW_REBOOT; + if (!(mig =3D qemuMigrationEatCookie(driver, vm, NULL, 0, 0))) goto cleanup; =20 @@ -2639,7 +2641,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, QEMU_MIGRATION_COOKIE_NBD | QEMU_MIGRATION_COOKIE_MEMORY_HOTPLU= G | QEMU_MIGRATION_COOKIE_CPU_HOTPLUG | - QEMU_MIGRATION_COOKIE_CPU))) + QEMU_MIGRATION_COOKIE_CPU | + QEMU_MIGRATION_COOKIE_ALLOW_REBOOT)= )) goto cleanup; =20 if (STREQ_NULLABLE(protocol, "rdma") && @@ -2679,6 +2682,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, goto stopjob; stopProcess =3D true; =20 + priv->allowReboot =3D mig->allowReboot; + if (!(incoming =3D qemuMigrationPrepareIncoming(vm, tunnel, protocol, listenAddress, port, dataFD[0]))) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index bc6a8dc552..2877913793 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -49,7 +49,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag, "statistics", "memory-hotplug", "cpu-hotplug", - "cpu"); + "cpu", + "allowReboot"); =20 =20 static void @@ -538,6 +539,18 @@ qemuMigrationCookieAddCPU(qemuMigrationCookiePtr mig, =20 =20 static void +qemuMigrationCookieAddAllowReboot(qemuMigrationCookiePtr mig, + virDomainObjPtr vm) +{ + qemuDomainObjPrivatePtr priv =3D vm->privateData; + + mig->allowReboot =3D priv->allowReboot; + + mig->flags |=3D QEMU_MIGRATION_COOKIE_ALLOW_REBOOT; +} + + +static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf, qemuMigrationCookieGraphicsPtr grap) { @@ -777,6 +790,9 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, if (mig->flags & QEMU_MIGRATION_COOKIE_CPU && mig->cpu) virCPUDefFormatBufFull(buf, mig->cpu, NULL); =20 + if (mig->flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT) + qemuDomainObjPrivateXMLFormatAllowReboot(buf, mig->allowReboot); + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; @@ -1225,6 +1241,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu)= < 0) goto error; =20 + if (flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT && + qemuDomainObjPrivateXMLParseAllowReboot(ctxt, &mig->allowReboot) <= 0) + goto error; + virObjectUnref(caps); return 0; =20 @@ -1305,6 +1325,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig, qemuMigrationCookieAddCPU(mig, dom) < 0) return -1; =20 + if (flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT) + qemuMigrationCookieAddAllowReboot(mig, dom); + if (!(*cookieout =3D qemuMigrationCookieXMLFormatStr(driver, mig))) return -1; =20 diff --git a/src/qemu/qemu_migration_cookie.h b/src/qemu/qemu_migration_coo= kie.h index e5f3d75a95..4a25511a9a 100644 --- a/src/qemu/qemu_migration_cookie.h +++ b/src/qemu/qemu_migration_cookie.h @@ -29,6 +29,7 @@ typedef enum { QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG, QEMU_MIGRATION_COOKIE_FLAG_CPU_HOTPLUG, QEMU_MIGRATION_COOKIE_FLAG_CPU, + QEMU_MIGRATION_COOKIE_FLAG_ALLOW_REBOOT, =20 QEMU_MIGRATION_COOKIE_FLAG_LAST } qemuMigrationCookieFlags; @@ -45,6 +46,7 @@ typedef enum { QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG =3D (1 << QEMU_MIGRATION_COOKIE_F= LAG_MEMORY_HOTPLUG), QEMU_MIGRATION_COOKIE_CPU_HOTPLUG =3D (1 << QEMU_MIGRATION_COOKIE_FLAG= _CPU_HOTPLUG), QEMU_MIGRATION_COOKIE_CPU =3D (1 << QEMU_MIGRATION_COOKIE_FLAG_CPU), + QEMU_MIGRATION_COOKIE_ALLOW_REBOOT =3D (1 << QEMU_MIGRATION_COOKIE_FLA= G_ALLOW_REBOOT), } qemuMigrationCookieFeatures; =20 typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics; @@ -127,6 +129,9 @@ struct _qemuMigrationCookie { =20 /* If flags & QEMU_MIGRATION_COOKIE_CPU */ virCPUDefPtr cpu; + + /* If flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT */ + virTristateBool allowReboot; }; =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 21:05:03 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150815203597196.81727980418759; Mon, 16 Oct 2017 04:07:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BFF38C0587D7; Mon, 16 Oct 2017 11:07:14 +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 98332619CE; Mon, 16 Oct 2017 11:07:14 +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 5CD2C18355DE; Mon, 16 Oct 2017 11:07:14 +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 v9GB6h8Q008784 for ; Mon, 16 Oct 2017 07:06:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73DE05D961; Mon, 16 Oct 2017 11:06:43 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id F06D75D964 for ; Mon, 16 Oct 2017 11:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BFF38C0587D7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Pavel Hrdina To: libvir-list@redhat.com Date: Mon, 16 Oct 2017 13:06:27 +0200 Message-Id: <1726b6aa3153d6915a2031c797ed5397bfda3476.1508151956.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/14] qemu: implement virDomainSetLifecycleAction() 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 16 Oct 2017 11:07:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There is one limitation for using this API, when the guest is started with all actions set to "destroy" we put "-no-reboot" on the QEMU command line. That cannot be changed while QEMU is running and the QEMU process is always terminated no matter what is configured for any action. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1460677 Signed-off-by: Pavel Hrdina Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 4 +++ src/libvirt-domain.c | 4 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 94 ++++++++++++++++++++++++++++++++++++++++++++= +++- 5 files changed, 103 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f69bcc2530..feea8523a7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5612,7 +5612,7 @@ virDomainDefCheckDuplicateDriveAddresses(const virDom= ainDef *def) } =20 =20 -static bool +bool virDomainDefLifecycleActionAllowed(virDomainLifecycle type, virDomainLifecycleAction action) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8240433611..354b7adfa5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3409,4 +3409,8 @@ virDomainNetTypeSharesHostView(const virDomainNetDef = *net) return false; } =20 +bool +virDomainDefLifecycleActionAllowed(virDomainLifecycle type, + virDomainLifecycleAction action); + #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index a51d8e3820..eaec0979ad 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12047,6 +12047,10 @@ virDomainSetBlockThreshold(virDomainPtr domain, * Changes the actions of lifecycle events for domain represented as * $action in the domain XML. * + * QEMU driver has a limitation that if all lifecycle events are set + * to destroy when the domain is started, it's not possible to change + * any action for running domain. + * * Returns 0 on success, -1 on failure. */ int virDomainSetLifecycleAction(virDomainPtr domain, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4cd328eded..a8983f2246 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -269,6 +269,7 @@ virDomainDefHasDeviceAddress; virDomainDefHasMemballoon; virDomainDefHasMemoryHotplug; virDomainDefHasVcpusOffline; +virDomainDefLifecycleActionAllowed; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; virDomainDefNeedsPlacementAdvice; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f7d713ab59..58a1c7d94e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20914,6 +20914,97 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, } =20 =20 +static void +qemuDomainModifyLifecycleAction(virDomainDefPtr def, + virDomainLifecycle type, + virDomainLifecycleAction action) +{ + switch (type) { + case VIR_DOMAIN_LIFECYCLE_POWEROFF: + def->onPoweroff =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_REBOOT: + def->onReboot =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_CRASH: + def->onCrash =3D action; + break; + case VIR_DOMAIN_LIFECYCLE_LAST: + break; + } +} + + + +static int +qemuDomainSetLifecycleAction(virDomainPtr dom, + unsigned int type, + unsigned int action, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv; + virDomainObjPtr vm =3D NULL; + virDomainDefPtr def =3D NULL; + virDomainDefPtr persistentDef =3D NULL; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!virDomainDefLifecycleActionAllowed(type, action)) + goto cleanup; + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + priv =3D vm->privateData; + + if (virDomainSetLifecycleActionEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) + goto cleanup; + + if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) + goto endjob; + + if (def) { + if (priv->allowReboot =3D=3D VIR_TRISTATE_BOOL_NO) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cannot update lifecycle action because QEMU " + "was started with -no-reboot option")); + goto endjob; + } + + qemuDomainModifyLifecycleAction(def, type, action); + + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, + vm, driver->caps) < 0) + goto endjob; + } + + if (persistentDef) { + qemuDomainModifyLifecycleAction(persistentDef, type, action); + + if (virDomainSaveConfig(cfg->configDir, driver->caps, + persistentDef) < 0) + goto endjob; + } + + ret =3D 0; + + endjob: + qemuDomainObjEndJob(driver, vm); + + cleanup: + virDomainObjEndAPI(&vm); + virObjectUnref(cfg); + return ret; +} + + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectOpen =3D qemuConnectOpen, /* 0.2.0 */ @@ -21131,7 +21222,8 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainGetGuestVcpus =3D qemuDomainGetGuestVcpus, /* 2.0.0 */ .domainSetGuestVcpus =3D qemuDomainSetGuestVcpus, /* 2.0.0 */ .domainSetVcpu =3D qemuDomainSetVcpu, /* 3.1.0 */ - .domainSetBlockThreshold =3D qemuDomainSetBlockThreshold /* 3.2.0 */ + .domainSetBlockThreshold =3D qemuDomainSetBlockThreshold, /* 3.2.0 */ + .domainSetLifecycleAction =3D qemuDomainSetLifecycleAction, /* 3.9.0 */ }; =20 =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list