On Tue, Jul 31, 2012 at 10:56:13PM +0400, Dmitry Guryanov wrote:
To create a new VM in Parallels Clud Server we should issue
"prlctl create" command, and give path to the directory,
where VM should be created. VM's storage will be in that
directory later. So in this first version find out location
of first VM's hard disk and create VM there.
Signed-off-by: Dmitry Guryanov <dguryanov(a)parallels.com>
---
src/parallels/parallels_driver.c | 82 ++++++++++++++++++++++++++++++++++++-
src/parallels/parallels_storage.c | 5 +--
src/parallels/parallels_utils.h | 2 +
3 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 54df6ce..a503fab 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -1542,6 +1542,77 @@ parallelsApplyChanges(virDomainObjPtr dom, virDomainDefPtr new)
return 0;
}
+static int
+parallelsCreateVm(virConnectPtr conn, virDomainDefPtr def)
+{
+ parallelsConnPtr privconn = conn->privateData;
+ int i;
+ virStorageVolDefPtr privvol = NULL;
+ virStoragePoolObjPtr pool = NULL;
+ virStorageVolPtr vol = NULL;
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ for (i = 0; i < def->ndisks; i++) {
+ if (def->disks[i]->device != VIR_DOMAIN_DISK_DEVICE_DISK)
+ continue;
+
+ vol = parallelsStorageVolumeLookupByPathLocked(conn, def->disks[i]->src);
+ if (!vol) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("Can't find volume with path '%s'"),
+ def->disks[i]->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 without hard disks"));
+ return -1;
+ }
This error message without context
[...]
@@ -1582,9 +1653,16 @@ parallelsDomainDefineXML(virConnectPtr conn,
const char *xml)
def = NULL;
} else {
- virReportError(VIR_ERR_NO_SUPPORT, "%s",
- _("Not implemented yet"));
+ if (parallelsCreateVm(conn, def))
goto cleanup;
+ if (parallelsLoadDomains(privconn, def->name))
+ goto cleanup;
+ dom = virDomainFindByName(&privconn->domains, def->name);
+ if (!dom) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Domain is not defined after creation"));
+ goto cleanup;
+ }
}
as well as this one led to 'make syntax-check errors', I squashed in
the following which looks a safe way to try to provide informations,
Daniel
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index e1bc83e..b57ac96 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -1568,7 +1568,8 @@ parallelsCreateVm(virConnectPtr conn, virDomainDefPtr def)
* let's report error if no disk until better solution
* will be found */
virReportError(VIR_ERR_INVALID_ARG,
- _("Can't create VM without hard disks"));
+ _("Can't create VM '%s' without hard
disks"),
+ (def->name ? def->name : "no name"));
return -1;
}
@@ -1657,7 +1658,8 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml)
dom = virDomainFindByName(&privconn->domains, def->name);
if (!dom) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Domain is not defined after creation"));
+ _("Domain for '%s' is not defined after
creation"),
+ (def->name ? def->name : "no name"));
goto cleanup;
}
}
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/