[Libvirt-cim] [PATCH] Be sure to check to see if the UUID is in use in both the DefineSystem()
Richard Maciel
rmaciel at linux.vnet.ibm.com
Mon Aug 24 15:00:38 UTC 2009
+1
On 08/20/2009 09:16 PM, Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert<karupert at us.ibm.com>
> # Date 1250813784 25200
> # Node ID 0243aa0574431112f0946354d4bbad62bb2c2f7b
> # Parent 7efea1d379a1b4de6c4d7583b456a0a00f80ad3b
> Be sure to check to see if the UUID is in use in both the DefineSystem()...
>
> and ModifySystemSettings() calls.
>
> Signed-off-by: Kaitlin Rupert<karupert at us.ibm.com>
>
> diff -r 7efea1d379a1 -r 0243aa057443 src/Virt_VirtualSystemManagementService.c
> --- a/src/Virt_VirtualSystemManagementService.c Wed Aug 19 22:47:17 2009 -0700
> +++ b/src/Virt_VirtualSystemManagementService.c Thu Aug 20 17:16:24 2009 -0700
> @@ -71,6 +71,37 @@
> RESOURCE_MOD,
> };
>
> +static CMPIStatus check_uuid_in_use(const CMPIObjectPath *ref,
> + struct domain *domain)
> +{
> + CMPIStatus s = {CMPI_RC_OK, NULL};
> + virConnectPtr conn = NULL;
> + virDomainPtr dom = NULL;
> +
> + conn = connect_by_classname(_BROKER, CLASSNAME(ref),&s);
> + if (conn == NULL) {
> + cu_statusf(_BROKER,&s,
> + CMPI_RC_ERR_FAILED,
> + "Error connecting to libvirt");
> + goto out;
> + }
> +
> + dom = virDomainLookupByUUIDString(conn, domain->uuid);
> + if (dom != NULL) {
> + cu_statusf(_BROKER,&s,
> + CMPI_RC_ERR_FAILED,
> + "Guest '%s' is already defined with UUID %s",
> + virDomainGetName(dom),
> + domain->uuid);
> + }
> +
> + out:
> + virDomainFree(dom);
> + virConnectClose(conn);
> +
> + return s;
> +}
> +
> static CMPIStatus define_system_parse_args(const CMPIArgs *argsin,
> CMPIInstance **sys,
> const char *ns,
> @@ -1402,26 +1433,10 @@
> goto out;
> }
>
> - if (domain->uuid != NULL) {
> - conn = connect_by_classname(_BROKER, CLASSNAME(ref), s);
> - if (conn == NULL) {
> - cu_statusf(_BROKER, s,
> - CMPI_RC_ERR_FAILED,
> - "Error connecting to libvirt");
> - goto out;
> - }
> -
> - dom = virDomainLookupByUUIDString(conn, domain->uuid);
> - if (dom != NULL) {
> - cu_statusf(_BROKER, s,
> - CMPI_RC_ERR_FAILED,
> - "Guest '%s' is already defined with UUID %s",
> - virDomainGetName(dom),
> - domain->uuid);
> - goto out;
> - }
> - }
> -
> + *s = check_uuid_in_use(ref, domain);
> + if (s->rc != CMPI_RC_OK)
> + goto out;
> +
> msg = classify_resources(resources, NAMESPACE(ref), domain);
> if (msg != NULL) {
> CU_DEBUG("Failed to classify resources: %s", msg);
> @@ -1644,6 +1659,10 @@
> goto out;
> }
>
> + s = check_uuid_in_use(ref, dominfo);
> + if (s.rc != CMPI_RC_OK)
> + goto out;
> +
> xml = system_to_xml(dominfo);
> if (xml != NULL) {
> CU_DEBUG("New XML is:\n%s", xml);
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Richard Maciel, MSc
IBM Linux Technology Center
rmaciel at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list