[PATCH] PHYP: Checking for NULL values when building new guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When creating a new gust, the function phypBuildLpar() was not
checking for NULL values, making the driver to have a segmentation
fault.
---
 src/phyp/phyp_driver.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 251111d..999870e 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3701,6 +3701,25 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def)
     int exit_status = 0;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
+    if (!def->name) {
+        VIR_ERROR0(_("Field \"<name>\" on the domain XML file missing."));
+        goto err;
+    } else if (!def->memory) {
+        VIR_ERROR0(_
+                   ("Field \"<memory>\" on the domain XML file missing."));
+        goto err;
+    } else if (!def->maxmem) {
+        VIR_ERROR0(_
+                   ("Field \"<currentMemory>\" on the domain XML file missing."));
+        goto err;
+    } else if (!def->vcpus) {
+        VIR_ERROR0(_("Field \"<vcpu>\" on the domain XML file missing."));
+        goto err;
+    } else if (!def->disks[0]->src) {
+        VIR_ERROR0(_("Field \"<disk>\" on the domain XML file missing."));
+        goto err;
+    }
+
     virBufferAddLit(&buf, "mksyscfg");
     if (system_type == HMC)
         virBufferVSprintf(&buf, " -m %s", managed_system);
-- 
1.7.0.4

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]