Re: [libvirt] [PATCH 06/10] conf: Add VM Generation ID parse/format support

2018-04-12 Thread Marc Hartmayer
On Thu, Apr 12, 2018 at 01:03 PM +0200, John Ferlan  wrote:
> [...]
>
>>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>>> index 385ba4ce8c..0fa9386270 100644
>>> --- a/src/conf/domain_conf.c
>>> +++ b/src/conf/domain_conf.c
>>> @@ -18791,6 +18791,34 @@ virDomainDefParseXML(xmlDocPtr xml,
>>>  VIR_FREE(tmp);
>>>  }
>>>
>>> +/* Extract domain genid - a genid can either be provided or generated 
>>> */
>>> +if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0)
>>> +goto error;
>>> +
>>> +if (n > 0) {
>>> +if (n != 1) {
>>> +virReportError(VIR_ERR_XML_ERROR, "%s",
>>> +  _("element 'genid' can only appear once"));
>>> +goto error;
>>> +}
>>> +def->genidRequested = true;
>>> +if (!(tmp = virXPathString("string(./genid[1])", ctxt))) {
>>> +if (virUUIDGenerate(def->genid) < 0) {
>>> +virReportError(VIR_ERR_INTERNAL_ERROR,
>>> +   "%s", _("Failed to generate genid"));
>>> +goto error;
>>> +}
>>> +def->genidGenerated = true;
>>> +} else {
>>> +if (virUUIDParse(tmp, def->genid) < 0) {
>>
>> You haven’t added these struct members to _virDomainDef (genid and
>> genidRequested) anywhere.
>>
>
> Patch 4 does that; however, there's been some list send/receive issues
> over the last 24 hours, so if that hasn't shown up in your inbox maybe
> it will today at some point...

Yay :D

>
> I split things up that way to reduce the amount of lines to review in
> one patch - in reality patches 4-6 could be one patch...
>
> John
>
>>> +virReportError(VIR_ERR_INTERNAL_ERROR,
>>> +   "%s", _("malformed genid element"));
>>> +goto error;
>>> +}
>>> +}
>>> +}
>>
>> […snip]
>>
>
--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 06/10] conf: Add VM Generation ID parse/format support

2018-04-12 Thread John Ferlan
[...]

>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 385ba4ce8c..0fa9386270 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -18791,6 +18791,34 @@ virDomainDefParseXML(xmlDocPtr xml,
>>  VIR_FREE(tmp);
>>  }
>>
>> +/* Extract domain genid - a genid can either be provided or generated */
>> +if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0)
>> +goto error;
>> +
>> +if (n > 0) {
>> +if (n != 1) {
>> +virReportError(VIR_ERR_XML_ERROR, "%s",
>> +  _("element 'genid' can only appear once"));
>> +goto error;
>> +}
>> +def->genidRequested = true;
>> +if (!(tmp = virXPathString("string(./genid[1])", ctxt))) {
>> +if (virUUIDGenerate(def->genid) < 0) {
>> +virReportError(VIR_ERR_INTERNAL_ERROR,
>> +   "%s", _("Failed to generate genid"));
>> +goto error;
>> +}
>> +def->genidGenerated = true;
>> +} else {
>> +if (virUUIDParse(tmp, def->genid) < 0) {
> 
> You haven’t added these struct members to _virDomainDef (genid and
> genidRequested) anywhere.
> 

Patch 4 does that; however, there's been some list send/receive issues
over the last 24 hours, so if that hasn't shown up in your inbox maybe
it will today at some point...

I split things up that way to reduce the amount of lines to review in
one patch - in reality patches 4-6 could be one patch...

John

>> +virReportError(VIR_ERR_INTERNAL_ERROR,
>> +   "%s", _("malformed genid element"));
>> +goto error;
>> +}
>> +}
>> +}
> 
> […snip]
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 06/10] conf: Add VM Generation ID parse/format support

2018-04-12 Thread Marc Hartmayer
On Wed, Apr 11, 2018 at 10:10 PM +0200, John Ferlan  wrote:
> The VM Generation ID is a mechanism to provide a unique 128-bit,
> cryptographically random, and integer value identifier known as
> the GUID (Globally Unique Identifier) to the guest OS. The value
> is used to help notify the guest operating system when the virtual
> machine is executed with a different configuration.
>
> This patch adds support for a new "genid" XML element similar to
> the "uuid" element. The "genid" element can have two forms ""
> or "$GUID". If the $GUID is not provided, libvirt
> will generate one.
>
> For the ABI checks add avoidance for the genid comparison if the
> appropriate flag is set.
>
> Since adding support for a generated GUID (or UUID like) value to
> be displayed only for an active guest, modifying the xml2xml test
> to include virrandommock.so is necessary since it will generate a
> "known" UUID value that can be compared against for the active test.
>
> Signed-off-by: John Ferlan 
> ---
>  docs/formatdomain.html.in| 29 
>  docs/schemas/domaincommon.rng|  8 
>  src/conf/domain_conf.c   | 59 
> 
>  src/conf/domain_conf.h   |  3 ++
>  tests/qemuxml2argvdata/genid-auto.xml| 32 +
>  tests/qemuxml2argvdata/genid.xml | 32 +
>  tests/qemuxml2xmloutdata/genid-active.xml| 32 +
>  tests/qemuxml2xmloutdata/genid-auto-active.xml   | 32 +
>  tests/qemuxml2xmloutdata/genid-auto-inactive.xml | 32 +
>  tests/qemuxml2xmloutdata/genid-inactive.xml  | 32 +
>  tests/qemuxml2xmltest.c  |  5 +-
>  11 files changed, 295 insertions(+), 1 deletion(-)
>  create mode 100644 tests/qemuxml2argvdata/genid-auto.xml
>  create mode 100644 tests/qemuxml2argvdata/genid.xml
>  create mode 100644 tests/qemuxml2xmloutdata/genid-active.xml
>  create mode 100644 tests/qemuxml2xmloutdata/genid-auto-active.xml
>  create mode 100644 tests/qemuxml2xmloutdata/genid-auto-inactive.xml
>  create mode 100644 tests/qemuxml2xmloutdata/genid-inactive.xml
>
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 5e99884dc5..fe9c3b19f0 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -34,6 +34,7 @@
>  
>MyGuest
>4dea22b3-1d52-d8f3-2516-782e98ab3fa0
> +  43dc0cf8-809b-4adb-9bea-a9abb5f3d90e
>A short description - title - of the domain
>Some human readable description
>
> @@ -61,6 +62,34 @@
>  specification. Since 0.0.1, sysinfo
>  since 0.8.7
>
> +  genid
> +  Since 4.3.0, the genid
> +element can be used to add a Virtual Machine Generation ID which
> +exposes a 128-bit, cryptographically random, integer value 
> identifier,
> +referred to as a Globally Unique Identifier (GUID) using the same
> +format as the uuid. The value is used to help notify
> +the guest operating system when the virtual machine is executed
> +with a different configuration, such as:
> +
> +
> +  snapshot execution
> +  backup recovery
> +  failover in a disaster recovery environment
> +  creation from template (import, copy, clone)
> +
> +
> +The guest operating system notices the change and is then able to
> +react as appropriate by marking its copies of distributed databases
> +as dirty, re-initializing its random number generator, etc.
> +
> +
> +When a GUID value is not provided, e.g. using the XML syntax
> +, then libvirt will automatically generate a GUID.
> +This is the recommended configuration since the hypervisor then
> +can handle changing the GUID value for specific state transitions.
> +Using a static GUID value may result in failures for starting from
> +snapshot, restoring from backup, starting a cloned domain, 
> etc.
> +
>title
>The optional element title provides space for a
>  short description of the domain. The title should not contain
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 4cab55f05d..1892a7c63c 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -502,6 +502,14 @@
>
>  
>
> +  
> +
> +  
> +
> +
> +  
> +
> +  
>  
>
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 385ba4ce8c..0fa9386270 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -18791,6 +18791,34 @@ virDomainDefParseXML(xmlDocPtr xml,
>  VIR_FREE(tmp);
>  }
>
> +/* Extract domain genid 

[libvirt] [PATCH 06/10] conf: Add VM Generation ID parse/format support

2018-04-11 Thread John Ferlan
The VM Generation ID is a mechanism to provide a unique 128-bit,
cryptographically random, and integer value identifier known as
the GUID (Globally Unique Identifier) to the guest OS. The value
is used to help notify the guest operating system when the virtual
machine is executed with a different configuration.

This patch adds support for a new "genid" XML element similar to
the "uuid" element. The "genid" element can have two forms ""
or "$GUID". If the $GUID is not provided, libvirt
will generate one.

For the ABI checks add avoidance for the genid comparison if the
appropriate flag is set.

Since adding support for a generated GUID (or UUID like) value to
be displayed only for an active guest, modifying the xml2xml test
to include virrandommock.so is necessary since it will generate a
"known" UUID value that can be compared against for the active test.

Signed-off-by: John Ferlan 
---
 docs/formatdomain.html.in| 29 
 docs/schemas/domaincommon.rng|  8 
 src/conf/domain_conf.c   | 59 
 src/conf/domain_conf.h   |  3 ++
 tests/qemuxml2argvdata/genid-auto.xml| 32 +
 tests/qemuxml2argvdata/genid.xml | 32 +
 tests/qemuxml2xmloutdata/genid-active.xml| 32 +
 tests/qemuxml2xmloutdata/genid-auto-active.xml   | 32 +
 tests/qemuxml2xmloutdata/genid-auto-inactive.xml | 32 +
 tests/qemuxml2xmloutdata/genid-inactive.xml  | 32 +
 tests/qemuxml2xmltest.c  |  5 +-
 11 files changed, 295 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/genid-auto.xml
 create mode 100644 tests/qemuxml2argvdata/genid.xml
 create mode 100644 tests/qemuxml2xmloutdata/genid-active.xml
 create mode 100644 tests/qemuxml2xmloutdata/genid-auto-active.xml
 create mode 100644 tests/qemuxml2xmloutdata/genid-auto-inactive.xml
 create mode 100644 tests/qemuxml2xmloutdata/genid-inactive.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5e99884dc5..fe9c3b19f0 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -34,6 +34,7 @@
 
   MyGuest
   4dea22b3-1d52-d8f3-2516-782e98ab3fa0
+  43dc0cf8-809b-4adb-9bea-a9abb5f3d90e
   A short description - title - of the domain
   Some human readable description
   
@@ -61,6 +62,34 @@
 specification. Since 0.0.1, sysinfo
 since 0.8.7
 
+  genid
+  Since 4.3.0, the genid
+element can be used to add a Virtual Machine Generation ID which
+exposes a 128-bit, cryptographically random, integer value identifier,
+referred to as a Globally Unique Identifier (GUID) using the same
+format as the uuid. The value is used to help notify
+the guest operating system when the virtual machine is executed
+with a different configuration, such as:
+
+
+  snapshot execution
+  backup recovery
+  failover in a disaster recovery environment
+  creation from template (import, copy, clone)
+
+
+The guest operating system notices the change and is then able to
+react as appropriate by marking its copies of distributed databases
+as dirty, re-initializing its random number generator, etc.
+
+
+When a GUID value is not provided, e.g. using the XML syntax
+, then libvirt will automatically generate a GUID.
+This is the recommended configuration since the hypervisor then
+can handle changing the GUID value for specific state transitions.
+Using a static GUID value may result in failures for starting from
+snapshot, restoring from backup, starting a cloned domain, 
etc.
+
   title
   The optional element title provides space for a
 short description of the domain. The title should not contain
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4cab55f05d..1892a7c63c 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -502,6 +502,14 @@
   
 
   
+  
+
+  
+
+
+  
+
+  
 
   
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 385ba4ce8c..0fa9386270 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18791,6 +18791,34 @@ virDomainDefParseXML(xmlDocPtr xml,
 VIR_FREE(tmp);
 }
 
+/* Extract domain genid - a genid can either be provided or generated */
+if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0)
+goto error;
+
+if (n > 0) {
+if (n != 1) {
+virReportError(VIR_ERR_XML_ERROR, "%s",
+  _("element 'genid' can only appear