[libvirt] [PATCH] storage: List directory volumes for dir/fs/netfs pools
by Cole Robinson
Since directories can be used for <filesystem> passthrough, they are
basically storage volumes. Not sure if anyone has an opinion about
not listing directories like ., .., or lost+found, but this patch
doesn't do anything explicit with them.
---
src/storage/storage_backend.c | 34 +++++++++++++++++++++++++++-------
src/storage/storage_backend.h | 7 ++++++-
src/storage/storage_backend_fs.c | 14 ++++++++++----
src/util/storage_file.c | 30 +++++++++++++++++++++++++++++-
4 files changed, 72 insertions(+), 13 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 02e455f..bcb7db5 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1022,9 +1022,12 @@ virStorageBackendVolOpenCheckMode(const char *path, unsigned int flags)
mode = VIR_STORAGE_VOL_OPEN_CHAR;
else if (S_ISBLK(sb.st_mode))
mode = VIR_STORAGE_VOL_OPEN_BLOCK;
+ else if (S_ISDIR(sb.st_mode))
+ mode = VIR_STORAGE_VOL_OPEN_DIR;
if (!(mode & flags)) {
VIR_FORCE_CLOSE(fd);
+ VIR_INFO("Skipping volume '%s'", path);
if (mode & VIR_STORAGE_VOL_OPEN_ERROR) {
virStorageReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1047,11 +1050,13 @@ int virStorageBackendVolOpen(const char *path)
int
virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
unsigned long long *allocation,
- unsigned long long *capacity)
+ unsigned long long *capacity,
+ unsigned int openflags)
{
int ret, fd;
- if ((ret = virStorageBackendVolOpen(target->path)) < 0)
+ if ((ret = virStorageBackendVolOpenCheckMode(target->path,
+ openflags)) < 0)
return ret;
fd = ret;
@@ -1066,24 +1071,34 @@ virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
}
int
-virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
- int withCapacity)
+virStorageBackendUpdateVolInfoFlags(virStorageVolDefPtr vol,
+ int withCapacity,
+ unsigned int openflags)
{
int ret;
if ((ret = virStorageBackendUpdateVolTargetInfo(&vol->target,
- &vol->allocation,
- withCapacity ? &vol->capacity : NULL)) < 0)
+ &vol->allocation,
+ withCapacity ? &vol->capacity : NULL,
+ openflags)) < 0)
return ret;
if (vol->backingStore.path &&
(ret = virStorageBackendUpdateVolTargetInfo(&vol->backingStore,
- NULL, NULL)) < 0)
+ NULL, NULL,
+ VIR_STORAGE_VOL_OPEN_DEFAULT)) < 0)
return ret;
return 0;
}
+int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
+ int withCapacity)
+{
+ return virStorageBackendUpdateVolInfoFlags(vol, withCapacity,
+ VIR_STORAGE_VOL_OPEN_DEFAULT);
+}
+
/*
* virStorageBackendUpdateVolTargetInfoFD:
* @conn: connection to report errors on
@@ -1125,6 +1140,11 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
*/
if (capacity)
*capacity = sb.st_size;
+ } else if (S_ISDIR(sb.st_mode)) {
+ *allocation = 0;
+ if (capacity)
+ *capacity = 0;
+
} else {
off_t end;
/* XXX this is POSIX compliant, but doesn't work for CHAR files,
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index fcfbed0..67ac32c 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -93,6 +93,7 @@ enum {
VIR_STORAGE_VOL_OPEN_REG = 1 << 1, /* regular files okay */
VIR_STORAGE_VOL_OPEN_BLOCK = 1 << 2, /* block files okay */
VIR_STORAGE_VOL_OPEN_CHAR = 1 << 3, /* char files okay */
+ VIR_STORAGE_VOL_OPEN_DIR = 1 << 4, /* directories okay */
};
# define VIR_STORAGE_VOL_OPEN_DEFAULT (VIR_STORAGE_VOL_OPEN_ERROR |\
@@ -107,9 +108,13 @@ ATTRIBUTE_NONNULL(1);
int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
int withCapacity);
+int virStorageBackendUpdateVolInfoFlags(virStorageVolDefPtr vol,
+ int withCapacity,
+ unsigned int openflags);
int virStorageBackendUpdateVolTargetInfo(virStorageVolTargetPtr target,
unsigned long long *allocation,
- unsigned long long *capacity);
+ unsigned long long *capacity,
+ unsigned int openflags);
int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
int fd,
unsigned long long *allocation,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index b8d4d63..3f4d978 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -48,6 +48,11 @@
#define VIR_FROM_THIS VIR_FROM_STORAGE
+#define VIR_STORAGE_VOL_FS_OPEN_FLAGS (VIR_STORAGE_VOL_OPEN_DEFAULT |\
+ VIR_STORAGE_VOL_OPEN_DIR)
+#define VIR_STORAGE_VOL_FS_REFRESH_FLAGS (VIR_STORAGE_VOL_FS_OPEN_FLAGS &\
+ ~VIR_STORAGE_VOL_OPEN_ERROR)
+
static int ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
virStorageBackendProbeTarget(virStorageVolTargetPtr target,
char **backingStore,
@@ -65,7 +70,7 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target,
*encryption = NULL;
if ((ret = virStorageBackendVolOpenCheckMode(target->path,
- (VIR_STORAGE_VOL_OPEN_DEFAULT & ~VIR_STORAGE_VOL_OPEN_ERROR))) < 0)
+ VIR_STORAGE_VOL_FS_REFRESH_FLAGS)) < 0)
return ret; /* Take care to propagate ret, it is not always -1 */
fd = ret;
@@ -676,8 +681,8 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
vol->backingStore.format = backingStoreFormat;
if (virStorageBackendUpdateVolTargetInfo(&vol->backingStore,
- NULL,
- NULL) < 0) {
+ NULL, NULL,
+ VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) {
/* The backing file is currently unavailable, the capacity,
* allocation, owner, group and mode are unknown. Just log the
* error an continue.
@@ -941,7 +946,8 @@ virStorageBackendFileSystemVolRefresh(virConnectPtr conn,
int ret;
/* Refresh allocation / permissions info in case its changed */
- ret = virStorageBackendUpdateVolInfo(vol, 0);
+ ret = virStorageBackendUpdateVolInfoFlags(vol, 0,
+ VIR_STORAGE_VOL_FS_OPEN_FLAGS);
if (ret < 0)
return ret;
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index ede79fa..8dbd933 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -24,6 +24,7 @@
#include <config.h>
#include "storage_file.h"
+#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#ifdef __linux__
@@ -736,6 +737,19 @@ virStorageFileProbeFormatFromFD(const char *path, int fd)
unsigned char *head;
ssize_t len = STORAGE_MAX_HEAD;
int ret = -1;
+ struct stat sb;
+
+ if (fstat(fd, &sb) < 0) {
+ virReportSystemError(errno,
+ _("cannot stat file '%s'"),
+ path);
+ return -1;
+ }
+
+ /* No header to probe for directories */
+ if (S_ISDIR(sb.st_mode)) {
+ return VIR_STORAGE_FILE_DIR;
+ }
if (VIR_ALLOC_N(head, len) < 0) {
virReportOOMError();
@@ -812,9 +826,10 @@ virStorageFileGetMetadataFromFD(const char *path,
int format,
virStorageFileMetadata *meta)
{
- unsigned char *head;
+ unsigned char *head = NULL;
ssize_t len = STORAGE_MAX_HEAD;
int ret = -1;
+ struct stat sb;
if (VIR_ALLOC_N(head, len) < 0) {
virReportOOMError();
@@ -823,6 +838,19 @@ virStorageFileGetMetadataFromFD(const char *path,
memset(meta, 0, sizeof (*meta));
+ if (fstat(fd, &sb) < 0) {
+ virReportSystemError(errno,
+ _("cannot stat file '%s'"),
+ path);
+ return -1;
+ }
+
+ /* No header to probe for directories */
+ if (S_ISDIR(sb.st_mode)) {
+ ret = 0;
+ goto cleanup;
+ }
+
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
virReportSystemError(errno, _("cannot seek to start of '%s'"), path);
goto cleanup;
--
1.7.4.4
13 years, 5 months
[libvirt] [PATCH 0/7] More remote generator work
by Matthias Bolte
This series removes special case code from the generator and moves
it to annotations in the .x files. There are also cleanups of sign
mismatches between the different API layers and additional moves of
functions to generated code.
This series superseds patch 4/5 of the last series [1] and implements
Eric's suggestions.
[1] https://www.redhat.com/archives/libvir-list/2011-May/msg00991.html
configure.ac | 1 +
daemon/remote.c | 289 ++-----------------------
daemon/remote_generator.pl | 473 ++++++++++++++++++++++++++++------------
src/driver.h | 2 +-
src/nwfilter/nwfilter_driver.c | 2 +-
src/remote/remote_driver.c | 268 ++--------------------
src/remote/remote_protocol.x | 247 +++++++++++----------
src/remote_protocol-structs | 40 ++--
8 files changed, 532 insertions(+), 790 deletions(-)
Matthias
13 years, 6 months
[libvirt] ruby libvirt restore is broken
by Ronen Narkis
Hey dear libvirt users /dev
Im trying to use ruby's bindings to libvirt and Im unable to use the domain
restore
ruby-1.8.7-p334 :014 > dom.restore("/tmp/puppet-client.state")
Libvirt::Error: Call to virDomainRestore failed
from (irb):14:in `restore'
from (irb):14
Iv taken a look into /var/log/libvirt/qemu/puppet-client.log
But there is no error there,
Any help will be appreciated,
Ronen
13 years, 6 months
[libvirt] [PATCH 0/3] support for changing memory parameters for inactive domains
by Hu Tao
This series enables user to change memory parameters for inactive
domains from virsh command line.
Hu Tao (3):
Add new flags for setting memory parameters
update qemuDomainGetMemoryParameters to use flags
update qemuDomainSetMemoryParameters to use flags
include/libvirt/libvirt.h.in | 7 ++
src/qemu/qemu_driver.c | 206 +++++++++++++++++++++++++++++++++---------
tools/virsh.c | 24 +++++-
tools/virsh.pod | 7 ++
4 files changed, 198 insertions(+), 46 deletions(-)
--
1.7.3.1
13 years, 6 months
[libvirt] [PATCH] tests: Test for SPICE compression options
by Michal Privoznik
and check regression
---
.../qemuxml2argv-graphics-spice-compression.args | 9 +++++
.../qemuxml2argv-graphics-spice-compression.xml | 39 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
tests/qemuxml2xmltest.c | 1 +
4 files changed, 52 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
new file mode 100644
index 0000000..531c567
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
+/dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
+x509-dir=/etc/pki/libvirt-spice,\
+image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
+playback-compression=on,streaming-video=filter -vga \
+qxl -global qxl.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
new file mode 100644
index 0000000..64a6890
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <currentMemory>219136</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'>
+ <image compression='auto_glz'/>
+ <jpeg compression='auto'/>
+ <zlib compression='auto'/>
+ <playback compression='on'/>
+ <streaming mode='filter'/>
+ </graphics>
+ <video>
+ <model type='qxl' vram='18432' heads='1'/>
+ </video>
+ <video>
+ <model type='qxl' vram='32768' heads='1'/>
+ </video>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a7e4cc0..33cc58f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -354,6 +354,9 @@ mymain(void)
DO_TEST("graphics-spice", false,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE);
+ DO_TEST("graphics-spice-compression", false,
+ QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE);
DO_TEST("graphics-spice-qxl-vga", false,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5bfbcab..1574cae 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -143,6 +143,7 @@ mymain(void)
DO_TEST("graphics-sdl");
DO_TEST("graphics-sdl-fullscreen");
DO_TEST("graphics-spice");
+ DO_TEST("graphics-spice-compression");
DO_TEST("graphics-spice-qxl-vga");
DO_TEST("input-usbmouse");
DO_TEST("input-usbtablet");
--
1.7.5.rc3
13 years, 6 months
[libvirt] [PATCH] Workaround apibuild.py warnings
by Matthias Bolte
Parsing ./../include/libvirt/libvirt.h
Misformatted macro comment for _virSchedParameter
Expecting '* _virSchedParameter:' got '* virSchedParameter:'
Misformatted macro comment for _virBlkioParameter
Expecting '* _virBlkioParameter:' got '* virBlkioParameter:'
Misformatted macro comment for _virMemoryParameter
Expecting '* _virMemoryParameter:' got '* virMemoryParameter:'
Replace '#define' with '# define' for the backward compatibility
defines to keep apibuild.py from parsing them and expecting
documentation comments for them.
---
include/libvirt/libvirt.h.in | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 8058229..424e49b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2569,7 +2569,7 @@ typedef enum {
* Provided for backwards compatibility; virTypedParameter is the
* preferred alias since 0.9.2.
*/
-#define _virSchedParameter _virTypedParameter
+# define _virSchedParameter _virTypedParameter
typedef struct _virTypedParameter virSchedParameter;
/**
@@ -2613,7 +2613,7 @@ typedef enum {
* Provided for backwards compatibility; virTypedParameter is the
* preferred alias since 0.9.2.
*/
-#define _virBlkioParameter _virTypedParameter
+# define _virBlkioParameter _virTypedParameter
typedef struct _virTypedParameter virBlkioParameter;
/**
@@ -2657,7 +2657,7 @@ typedef enum {
* Provided for backwards compatibility; virTypedParameter is the
* preferred alias since 0.9.2.
*/
-#define _virMemoryParameter _virTypedParameter
+# define _virMemoryParameter _virTypedParameter
typedef struct _virTypedParameter virMemoryParameter;
/**
--
1.7.0.4
13 years, 6 months
[libvirt] [PATCH] conf: Fix incorrect spice graphic XML format on compression options
by Michal Privoznik
If spice graphics has no <channel> elements, the output graphics XML
is messed up. To prevent this, we need to end the <graphics> element
just before adding any compression selecting elements.
---
src/conf/domain_conf.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3f2fb11..2800db5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8082,6 +8082,12 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
virDomainGraphicsSpiceChannelNameTypeToString(i),
virDomainGraphicsSpiceChannelModeTypeToString(mode));
}
+ if (!children && (def->data.spice.image || def->data.spice.jpeg ||
+ def->data.spice.zlib || def->data.spice.playback ||
+ def->data.spice.streaming)) {
+ virBufferAddLit(buf, ">\n");
+ children = 1;
+ }
if (def->data.spice.image)
virBufferAsprintf(buf, " <image compression='%s'/>\n",
virDomainGraphicsSpiceImageCompressionTypeToString(def->data.spice.image));
--
1.7.5.rc3
13 years, 6 months
[libvirt] [PATCH 0/4] Allow changing guest XML during QEMU migration
by Daniel P. Berrange
This patch series updates the QEMU driver to allow it to take
advantage of the migration v3 protocol support for changing
guest XML during migration.
eg
virsh migrate --xml migtest.xml migtest qemu+ssh://somehost/system
NB the XML is strictly validated for guest ABI compatibility
so only things like host NIC device names or host disk file
paths can be changed
13 years, 6 months
[libvirt] fix spice graphic format issue in function virDomainGraphicsDefFormat
by Chen Coolper
hi,
all sub item of spice graphics need to processed like spice channels, that
is adding the following lines:
if (!children) {
virBufferAddLit(buf, ">\n");
children = 1;
}
the following patch is generated base on git master.
-----------------------------------------------------------------------------------------
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b30acc8..e42db06 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8127,21 +8127,46 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
virDomainGraphicsSpiceChannelNameTypeToString(i),
virDomainGraphicsSpiceChannelModeTypeToString(mode));
}
- if (def->data.spice.image)
+ if (def->data.spice.image) {
virBufferAsprintf(buf, " <image compression='%s'/>\n",
virDomainGraphicsSpiceImageCompressionTypeToString(def->data.spice.image));
- if (def->data.spice.jpeg)
+ if (!children) {
+ virBufferAddLit(buf, ">\n");
+ children = 1;
+ }
+ }
+ if (def->data.spice.jpeg) {
virBufferAsprintf(buf, " <jpeg compression='%s'/>\n",
virDomainGraphicsSpiceJpegCompressionTypeToString(def->data.spice.jpeg));
- if (def->data.spice.zlib)
+ if (!children) {
+ virBufferAddLit(buf, ">\n");
+ children = 1;
+ }
+ }
+ if (def->data.spice.zlib) {
virBufferAsprintf(buf, " <zlib compression='%s'/>\n",
virDomainGraphicsSpiceZlibCompressionTypeToString(def->data.spice.zlib));
- if (def->data.spice.playback)
+ if (!children) {
+ virBufferAddLit(buf, ">\n");
+ children = 1;
+ }
+ }
+ if (def->data.spice.playback) {
virBufferAsprintf(buf, " <playback compression='%s'/>\n",
virDomainGraphicsSpicePlaybackCompressionTypeToString(def->data.spice.playback));
- if (def->data.spice.streaming)
+ if (!children) {
+ virBufferAddLit(buf, ">\n");
+ children = 1;
+ }
+ }
+ if (def->data.spice.streaming) {
virBufferAsprintf(buf, " <streaming mode='%s'/>\n",
virDomainGraphicsSpiceStreamingModeTypeToString(def->data.spice.streaming));
+ if (!children) {
+ virBufferAddLit(buf, ">\n");
+ children = 1;
+ }
+ }
}
if (children) {
--
Coolper Chen
13 years, 6 months
[libvirt] [PATCH] lxc: Seperate domain config loading
by Osier Yang
This patch seperate the domain config loading just as qemu driver
does, first loading config of running or trasient domains, then
of persistent inactive domains. And only try to reconnect the
monitor of running domains, so that it won't always throws errors
saying can't connect to domain monitor.
And as "virDomainLoadConfig->virDomainAssignDef->virDomainObjAssignDef",
already do things like "vm->newDef = def", removed the codes
in "lxcReconnectVM" that does the same work.
---
src/lxc/lxc_driver.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 2bb592d..ccf20e4 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1521,6 +1521,10 @@ static int lxcVmStart(virConnectPtr conn,
if (virDomainObjSetDefTransient(driver->caps, vm, false) < 0)
goto cleanup;
+ /* Write domain status to disk. */
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
+ goto cleanup;
+
rc = 0;
cleanup:
@@ -1586,7 +1590,6 @@ static int lxcDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STARTED,
VIR_DOMAIN_EVENT_STARTED_BOOTED);
-
cleanup:
if (vm)
virDomainObjUnlock(vm);
@@ -1925,18 +1928,6 @@ lxcReconnectVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
goto cleanup;
}
- if ((config = virDomainConfigFile(driver->stateDir,
- vm->def->name)) == NULL)
- goto cleanup;
-
- /* Try and load the live config */
- tmp = virDomainDefParseFile(driver->caps, config, 0);
- VIR_FREE(config);
- if (tmp) {
- vm->newDef = vm->def;
- vm->def = tmp;
- }
-
if (vm->pid != 0) {
vm->def->id = vm->pid;
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
@@ -2029,6 +2020,17 @@ static int lxcStartup(int privileged)
lxc_driver->caps->privateDataAllocFunc = lxcDomainObjPrivateAlloc;
lxc_driver->caps->privateDataFreeFunc = lxcDomainObjPrivateFree;
+ /* Get all the running persistent or transient configs first */
+ if (virDomainLoadAllConfigs(lxc_driver->caps,
+ &lxc_driver->domains,
+ lxc_driver->stateDir,
+ NULL,
+ 1, NULL, NULL) < 0)
+ goto cleanup;
+
+ virHashForEach(lxc_driver->domains.objs, lxcReconnectVM, lxc_driver);
+
+ /* Then inactive persistent configs */
if (virDomainLoadAllConfigs(lxc_driver->caps,
&lxc_driver->domains,
lxc_driver->configDir,
@@ -2036,8 +2038,6 @@ static int lxcStartup(int privileged)
0, NULL, NULL) < 0)
goto cleanup;
- virHashForEach(lxc_driver->domains.objs, lxcReconnectVM, lxc_driver);
-
lxcDriverUnlock(lxc_driver);
lxcAutostartConfigs(lxc_driver);
--
1.7.4
13 years, 6 months