提交 a9bd9b94 编写于 作者: D Dmitry Guryanov 提交者: Daniel Veillard

parallels: fill volumes capacity parameter

Read disk images size from xml description and fill
virStorageVolDef.capacity and allocation (let's consider
that allocation is the same as capacity, calculating real
allcoation will be implemented later).
Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
上级 9b4c03ae
......@@ -253,10 +253,57 @@ parallelsPoolAddByDomain(virConnectPtr conn, virDomainObjPtr dom)
return pool;
}
static int parallelsDiskDescParseNode(xmlDocPtr xml,
xmlNodePtr root,
virStorageVolDefPtr def)
{
xmlXPathContextPtr ctxt = NULL;
int ret;
if (STRNEQ((const char *)root->name, "Parallels_disk_image")) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("unknown root element for storage pool"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
virReportOOMError();
goto cleanup;
}
ctxt->node = root;
if (virXPathULongLong("string(./Disk_Parameters/Disk_size)",
ctxt, &def->capacity))
ret = -1;
def->capacity <<= 9;
def->allocation = def->capacity;
cleanup:
xmlXPathFreeContext(ctxt);
return ret;
}
static int parallelsDiskDescParse(const char *path, virStorageVolDefPtr def)
{
xmlDocPtr xml;
int ret = -1;
if (!(xml = virXMLParse(path, NULL, NULL)))
return -1;
ret = parallelsDiskDescParseNode(xml, xmlDocGetRootElement(xml), def);
xmlFreeDoc(xml);
return ret;
}
static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
virDomainObjPtr dom,
const char *diskName,
const char *diskPath)
const char *diskPath,
const char *diskDescPath)
{
virStorageVolDefPtr def = NULL;
......@@ -269,6 +316,8 @@ static int parallelsAddDiskVolume(virStoragePoolObjPtr pool,
def->type = VIR_STORAGE_VOL_FILE;
parallelsDiskDescParse(diskDescPath, def);
if (!(def->target.path = realpath(diskPath, NULL)))
goto no_memory;
......@@ -334,7 +383,8 @@ static int parallelsFindVmVolumes(virStoragePoolObjPtr pool,
/* here we know, that ent->d_name is a disk image directory */
if (parallelsAddDiskVolume(pool, dom, ent->d_name, diskPath))
if (parallelsAddDiskVolume(pool, dom, ent->d_name,
diskPath, diskDescPath))
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册