From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: [PATCH 6/6] xl: generate a new random VM generation ID if requested Date: Tue, 27 May 2014 18:31:49 +0100 Message-ID: <1401211909-27771-7-git-send-email-david.vrabel@citrix.com> References: <1401211909-27771-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WpLEG-00087K-7I for xen-devel@lists.xenproject.org; Tue, 27 May 2014 17:32:00 +0000 In-Reply-To: <1401211909-27771-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: David Vrabel , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org If the "generation_id" option is set in the domain configuration, generate and set a new random VM generation ID every time a domain is created or restored. xl lacks the infrastructure to fully track the lifecycle of VM images as they are snapshotted and cloned (etc) so always using a new ID is the safe option and ensures that a new one will be used where it matters. Signed-off-by: David Vrabel --- docs/man/xl.cfg.pod.5 | 14 ++++++++++++++ tools/libxl/xl_cmdimpl.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index 0ca37bc..0ec0386 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -936,6 +936,20 @@ number of vendor defined SMBIOS structures (type 128 - 255). Since SMBIOS structures do not present their overall size, each entry in the file must be preceded by a 32b integer indicating the size of the next structure. +=item B + +Provide a VM generation ID to the guest. + +The VM generation ID as a 128-bit random number that a guest may use +to determine if the guest has been restored from an earlier snapshot, +or cloned. + +This is required for Microsoft Windows Server 2012 (and later) domain +controllers. + +See also "Virtual Machine Generation ID" by Microsoft +(http://www.microsoft.com/en-us/download/details.aspx?id=30707). + =back =head3 Guest Virtual Time Controls diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 5195914..843ef14 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -155,6 +155,7 @@ struct domain_create { const char *restore_file; int migrate_fd; /* -1 means none */ char **migration_domname_r; /* from malloc */ + bool set_genid; }; @@ -1058,6 +1059,8 @@ static void parse_config_data(const char *config_source, &b_info->u.hvm.smbios_firmware, 0); xlu_cfg_replace_string(config, "acpi_firmware", &b_info->u.hvm.acpi_firmware, 0); + if (dom_info && !xlu_cfg_get_long(config, "generation_id", &l, 0)) + dom_info->set_genid = !!l; break; case LIBXL_DOMAIN_TYPE_PV: { @@ -2254,6 +2257,17 @@ start: if ( ret ) goto error_out; + /* Generate and set a new random VM Generation ID? */ + if (dom_info->set_genid) { + libxl_uuid genid; + + libxl_uuid_generate(&genid); + + ret = libxl_vm_generation_id_set(ctx, domid, &genid); + if (ret) + goto error_out; + } + /* If single vcpu to pcpu mapping was requested, honour it */ if (vcpu_to_pcpu) { libxl_bitmap vcpu_cpumap; -- 1.7.10.4