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

Re: [libvirt] [PATCH v2 3/9] pvs: add functions to list domains and get info



On 04/18/2012 02:07 PM, Dmitry Guryanov wrote:
PVS driver is 'stateless', like vmware or openvz drivers.
It collects information about domains during startup using
command-line utility prlctl. VMs in PVS identified by UUIDs
or unique names, which can be used as respective fields in
virDomainDef structure. Currently only basic info, like
description, virtual cpus number and memory amount implemented.
Quering devices information will be added in the next patches.

PVS does't support non-persistent domains - you can't run
a domain having only disk image, it must always be registered
in system.

Functions for quering domain info have been just copied from
test driver with some changes - they extract needed data from
previouly created list of virDomainObj objects.

Signed-off-by: Dmitry Guryanov<dguryanov parallels com>
---

[...]

+
  static virCapsPtr
  pvsBuildCapabilities(void)
  {
@@ -126,6 +135,206 @@ pvsGetCapabilities(virConnectPtr conn)
      return xml;
  }

+/*
+ * Must be called with privconn->lock held
+ */
+static virDomainObjPtr
+pvsLoadDomain(pvsConnPtr privconn, virJSONValuePtr jobj)
+{
+    virDomainObjPtr dom = NULL;
+    virDomainDefPtr def = NULL;
+    pvsDomObjPtr pdom = NULL;
+    virJSONValuePtr jobj2, jobj3;
+    const char *tmp;
+    unsigned int x;
+
+    if (VIR_ALLOC(def)<  0)
+        goto cleanup;

goto no_memory;

+
+    def->virtType = VIR_DOMAIN_VIRT_PVS;
+    def->id = -1;
+
+    tmp = virJSONValueObjectGetString(jobj, "Name");
+    if (!tmp) {
+        pvsParseError();
+        goto cleanup;
+    }
+    if (!(def->name = strdup(tmp)))
+        goto no_memory;
+
+    tmp = virJSONValueObjectGetString(jobj, "ID");
+    if (!tmp) {
+        pvsParseError();
+        goto cleanup;
+    }
+
+    if (virUUIDParse(tmp, def->uuid) == -1) {

Replace '== -1' with '< 0'.

+    tmp = virJSONValueObjectGetString(jobj3, "size");
+
+    def->mem.max_balloon = atoi(tmp);

I think you should use virStrToLong_ul here.


+    def->mem.max_balloon<<= 10;
+    def->mem.cur_balloon = def->mem.max_balloon;
+
+    if (!(def->os.type = strdup("hvm")))
+        goto no_memory;
+
+    if (!(def->os.init = strdup("/sbin/init")))
+        goto no_memory;
+
+    if (!(dom = virDomainAssignDef(privconn->caps,
+&privconn->domains, def, false)))
+        goto cleanup;
+    /* dom is locked here */
+
+    if (VIR_ALLOC(pdom))

if (VIR_ALLOC(pdom)<0)

   Stefan


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