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

Re: [libvirt] [PATCH 08/12] vcpu: support maxvcpu in domain_conf

On 10/01/2010 09:01 AM, Daniel Veillard wrote:
-    if (virXPathULong("string(./vcpu[1])", ctxt,&def->vcpus)<  0)
-        def->vcpus = 1;
+    if (virXPathULong("string(./vcpu[1])", ctxt,&count)<  0)
+        def->maxvcpus = 1;
+    else {
+        def->maxvcpus = count;
+        if (def->maxvcpus != count || count == 0) {
+            virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+                                 _("invalid maxvcpus %lu"), count);
+            goto error;
+        }
+    }

   Hum, virXPathULong will return -2 for an non ULong format, and we
discard the error by just setting up maxvcpus = 1 silently but on the
other hand we make a fuss about 0 being provided :-)
   If we start raising an error on invalid values maybe it should be
done for both (-2 need to be checked)

Which is better? Relying on the .rng file for error checking (in which case, XML has already been validated, so not only do we know virXPathULong would never return -2, but we also know that current='0' would fail validation, so v2 should drop the redundant check for 0), or repeat all error checking in the C code (in which case adding a check for virXPathULong == -2 is a good thing for v2)?

Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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