提交 4bafe312 编写于 作者: D Dmitry Guryanov 提交者: Daniel P. Berrange

parallels: create VMs in the default place

Each VM consists of a set of files in PCS: config, hard
disk images, log file, memory dump. All these files are stored
in a per-vm directory. When we create a new VM, we can ether specify
path to the VM or create the VM in a default path
(<default path>/<vm name>.pvm). This default path can be configured
with command
prlsrvctl user set --def-vm-home <path> command.

Currenty parallels driver creates VM in the same place, where first
hard disk is located. Let's change this logic and create VMs in
the default path. It will be much clearer and allow us to create
VMs without hard disks.
Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
上级 a15d8d71
...@@ -2177,74 +2177,17 @@ parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new) ...@@ -2177,74 +2177,17 @@ parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new)
} }
static int static int
parallelsCreateVm(virConnectPtr conn, virDomainDefPtr def) parallelsCreateVm(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainDefPtr def)
{ {
parallelsConnPtr privconn = conn->privateData;
size_t i;
virStorageVolDefPtr privvol = NULL;
virStoragePoolObjPtr pool = NULL;
virStorageVolPtr vol = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
const char *src;
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->device != VIR_DOMAIN_DISK_DEVICE_DISK)
continue;
src = virDomainDiskGetSource(def->disks[i]);
vol = parallelsStorageVolLookupByPathLocked(conn, src);
if (!vol) {
virReportError(VIR_ERR_INVALID_ARG,
_("Can't find volume with path '%s'"),
src);
return -1;
}
break;
}
if (!vol) {
/* We determine path to VM directory from volume, so
* let's report error if no disk until better solution
* will be found */
virReportError(VIR_ERR_INVALID_ARG,
_("Can't create VM '%s' without hard disks"),
def->name ? def->name : _("(unnamed)"));
return -1;
}
pool = virStoragePoolObjFindByName(&privconn->pools, vol->pool);
if (!pool) {
virReportError(VIR_ERR_INVALID_ARG,
_("Can't find storage pool with name '%s'"),
vol->pool);
goto error;
}
privvol = virStorageVolDefFindByPath(pool, src);
if (!privvol) {
virReportError(VIR_ERR_INVALID_ARG,
_("Can't find storage volume definition for path '%s'"),
src);
goto error2;
}
virUUIDFormat(def->uuid, uuidstr); virUUIDFormat(def->uuid, uuidstr);
if (parallelsCmdRun(PRLCTL, "create", def->name, "--dst", if (parallelsCmdRun(PRLCTL, "create", def->name, "--no-hdd",
pool->def->target.path, "--no-hdd",
"--uuid", uuidstr, NULL) < 0) "--uuid", uuidstr, NULL) < 0)
goto error2; return -1;
virStoragePoolObjUnlock(pool);
virObjectUnref(vol);
return 0; return 0;
error2:
virStoragePoolObjUnlock(pool);
error:
virObjectUnref(vol);
return -1;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册