On Thu, Jul 24, 2008 at 04:12:05PM +0100, Daniel P. Berrange wrote:
> On Thu, Jul 24, 2008 at 10:41:31AM -0400, Guido G?nther wrote:
> > On Thu, Jul 24, 2008 at 10:01:32AM +0100, Daniel P. Berrange wrote:
[..snip..]
> > > You need to check for UUID clash too.
> > Indeed. But before fixing this I wonder what the exact semantics of
> > domainCreateLinux are. Is it correct that we don't call
> > virDomainSaveConfiguration?
>
> Yes, that is correct.
>
> virDomainCreateLinux() starts a virtual machine with no config file. All
> trace of it will disappear when it shuts down - a so called 'transient'
> VM.
>
> Alternatively you can define the config first with virDomainDefineXML()
> and then start it based on this definition with virDomainCreate(). This
> gives you a persistent VM.
>
> Now, while a transient VM is running you can explicitly give it a config
> file by called virDomainDefineXML with the same uuid, thus turning it in
> to a persistent VM.
The attache patch also checks the uuid.
-- Guido
---
src/qemu_driver.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 4a0c06c..8015b63 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -63,6 +63,7 @@
#include "stats_linux.h"
#include "capabilities.h"
#include "memory.h"
+#include "uuid.h"
/* For storing short-lived temporary files. */
#define TEMPDIR LOCAL_STATE_DIR "/cache/libvirt"
@@ -2009,11 +2010,22 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
vm = virDomainFindByName(driver->domains, def->name);
if (vm && virDomainIsActive(vm)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
- _("domain %s is already defined and running"),
+ _("domain '%s' is already defined and running"),
def->name);
virDomainDefFree(def);
return NULL;
}
+ vm = virDomainFindByUUID(driver->domains, def->uuid);
+ if (vm && virDomainIsActive(vm)) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ virUUIDFormat(def->uuid, uuidstr);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
+ _("domain with uuid '%s' is already defined and running"),
+ uuidstr);
+ virDomainDefFree(def);
+ return NULL;
+ }
if (!(vm = virDomainAssignDef(conn,
&driver->domains,
--
1.5.6.3
--
Libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list