[Libvirt-cim] [PATCH] Verify specified UUID is not in use by existing guest
Richard Maciel
rmaciel at linux.vnet.ibm.com
Mon Jul 6 16:40:57 UTC 2009
+1
Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1245863542 25200
> # Node ID 7417f62e29eb8b37acb66e616e49f51901f610c6
> # Parent 76be9533b5bab87a55c14ab68640c82cfd400b7b
> Verify specified UUID is not in use by existing guest
>
> Before generating the XML needed to define a guest, make sure a guest with
> the same UUID is not already defined.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 76be9533b5ba -r 7417f62e29eb src/Virt_VirtualSystemManagementService.c
> --- a/src/Virt_VirtualSystemManagementService.c Wed Jun 24 09:06:46 2009 -0700
> +++ b/src/Virt_VirtualSystemManagementService.c Wed Jun 24 10:12:22 2009 -0700
> @@ -1243,6 +1243,8 @@
> CMPIInstance *inst = NULL;
> char *xml = NULL;
> const char *msg = NULL;
> + virConnectPtr conn = NULL;
> + virDomainPtr dom = NULL;
>
> struct domain *domain = NULL;
>
> @@ -1268,6 +1270,26 @@
> goto out;
> }
>
> + if (domain->uuid != NULL) {
> + conn = connect_by_classname(_BROKER, CLASSNAME(ref), NULL);
> + 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;
> + }
> + }
> +
> msg = classify_resources(resources, NAMESPACE(ref), domain);
> if (msg != NULL) {
> CU_DEBUG("Failed to classify resources: %s", msg);
> @@ -1295,6 +1317,8 @@
> out:
> cleanup_dominfo(&domain);
> free(xml);
> + virDomainFree(dom);
> + virConnectClose(conn);
>
> return inst;
> }
>
> _______________________________________________
> 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