]> xenbits.xensource.com Git - libvirt.git/commitdiff
phyp: Checking for NULL values when building new guest
authorEduardo Otubo <otubo@linux.vnet.ibm.com>
Wed, 29 Sep 2010 14:52:15 +0000 (16:52 +0200)
committerDaniel Veillard <veillard@redhat.com>
Wed, 29 Sep 2010 14:54:39 +0000 (16:54 +0200)
When creating a new gust, the function phypBuildLpar() was not
checking for NULL values

src/phyp/phyp_driver.c: check the definition arguments to avoid a segmentation
  fault in phypBuildLpar()

src/phyp/phyp_driver.c

index 8eeba73fb21bc80dd4c82fb4f9566937b39c8182..ab12392f27a6e5a9ec513af85d126b188a9c2a37 100644 (file)
@@ -3701,6 +3701,29 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
     int exit_status = 0;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
+    if (!def->memory) {
+        PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
+                _("Field \"<memory>\" on the domain XML file is missing or has "
+                    "invalid value."));
+        goto err;
+    }
+
+    if (!def->maxmem) {
+        PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
+                _("Field \"<currentMemory>\" on the domain XML file is missing or"
+                    " has invalid value."));
+        goto err;
+    }
+
+    if (def->ndisks > 0) {
+        if (!def->disks[0]->src) {
+            PHYP_ERROR(VIR_ERR_XML_ERROR,"%s",
+                    _("Field \"<src>\" under \"<disk>\" on the domain XML file is "
+                        "missing."));
+            goto err;
+        }
+    }
+
     virBufferAddLit(&buf, "mksyscfg");
     if (system_type == HMC)
         virBufferVSprintf(&buf, " -m %s", managed_system);