[libvirt] [PATCH v2] LXC: avoid useless duplicate memory free
by Gao feng
when lxcContainerIdentifyCGroups failed, the memory it allocated
has been freed, so we should not free this memory again in
lxcContainerSetupPivortRoot and lxcContainerSetupExtraMounts.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 9045a7d..24b1017 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1323,7 +1323,7 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
/* Before pivoting we need to identify any
* cgroups controllers that are mounted */
if (lxcContainerIdentifyCGroups(&mounts, &nmounts) < 0)
- goto cleanup;
+ return -1;
/* Gives us a private root, leaving all parent OS mounts on /.oldroot */
if (lxcContainerPivotRoot(root) < 0)
@@ -1406,7 +1406,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef,
/* Before replacing /sys we need to identify any
* cgroups controllers that are mounted */
if (lxcContainerIdentifyCGroups(&mounts, &nmounts) < 0)
- goto cleanup;
+ return -1;
/* Gets rid of any existing stuff under /proc, since we need new
* namespace aware versions of those. We must do /proc second
--
1.7.7.6
12 years, 10 months
[libvirt] [PATCHv2] adding handling EINTR to poll to make it more robust
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
some system call and signal will interrupt poll,
making event loop stops and fails to react events and keepalive message
from libvirt.
adding handling EINTR to poll to make it more robust
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
examples/domain-events/events-python/event-test.py | 95 +++++++++++---------
1 files changed, 51 insertions(+), 44 deletions(-)
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
index 96dc268..7832d13 100644
--- a/examples/domain-events/events-python/event-test.py
+++ b/examples/domain-events/events-python/event-test.py
@@ -2,9 +2,9 @@
#
#
#
-#################################################################################
+##############################################################################
# Start off by implementing a general purpose event loop for anyones use
-#################################################################################
+##############################################################################
import sys
import getopt
@@ -27,11 +27,14 @@ import threading
use_pure_python_event_loop = True
do_debug = False
+
+
def debug(msg):
global do_debug
if do_debug:
print msg
+
#
# This general purpose event loop will support waiting for file handle
# I/O and errors events, as well as scheduling repeatable timers with
@@ -97,7 +100,6 @@ class virEventLoopPure:
self.cb(self.timer,
self.opaque)
-
def __init__(self):
self.poll = select.poll()
self.pipetrick = os.pipe()
@@ -178,48 +180,53 @@ class virEventLoopPure:
def run_once(self):
sleep = -1
self.runningPoll = True
- next = self.next_timeout()
- debug("Next timeout due at %d" % next)
- if next > 0:
- now = int(time.time() * 1000)
- if now >= next:
- sleep = 0
- else:
- sleep = (next - now) / 1000.0
-
- debug("Poll with a sleep of %d" % sleep)
- events = self.poll.poll(sleep)
-
- # Dispatch any file handle events that occurred
- for (fd, revents) in events:
- # See if the events was from the self-pipe
- # telling us to wakup. if so, then discard
- # the data just continue
- if fd == self.pipetrick[0]:
- self.pendingWakeup = False
- data = os.read(fd, 1)
- continue
-
- h = self.get_handle_by_fd(fd)
- if h:
- debug("Dispatch fd %d handle %d events %d" % (fd, h.get_id(), revents))
- h.dispatch(self.events_from_poll(revents))
+ try:
+ next = self.next_timeout()
+ debug("Next timeout due at %d" % next)
+ if next > 0:
+ now = int(time.time() * 1000)
+ if now >= next:
+ sleep = 0
+ else:
+ sleep = (next - now) / 1000.0
+
+ debug("Poll with a sleep of %d" % sleep)
+ events = self.poll.poll(sleep)
+
+ # Dispatch any file handle events that occurred
+ for (fd, revents) in events:
+ # See if the events was from the self-pipe
+ # telling us to wakup. if so, then discard
+ # the data just continue
+ if fd == self.pipetrick[0]:
+ self.pendingWakeup = False
+ data = os.read(fd, 1)
+ continue
+
+ h = self.get_handle_by_fd(fd)
+ if h:
+ debug("Dispatch fd %d handle %d events %d" % (fd, h.get_id(), revents))
+ h.dispatch(self.events_from_poll(revents))
- now = int(time.time() * 1000)
- for t in self.timers:
- interval = t.get_interval()
- if interval < 0:
- continue
-
- want = t.get_last_fired() + interval
- # Deduct 20ms, since schedular timeslice
- # means we could be ever so slightly early
- if now >= (want-20):
- debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
- t.set_last_fired(now)
- t.dispatch()
-
- self.runningPoll = False
+ now = int(time.time() * 1000)
+ for t in self.timers:
+ interval = t.get_interval()
+ if interval < 0:
+ continue
+
+ want = t.get_last_fired() + interval
+ # Deduct 20ms, since schedular timeslice
+ # means we could be ever so slightly early
+ if now >= (want-20):
+ debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
+ t.set_last_fired(now)
+ t.dispatch()
+
+ except (os.error, select.error), e:
+ if e.errno != errno.EINTR:
+ raise
+ finally:
+ self.runningPoll = False
# Actually the event loop forever
--
1.7.7.6
12 years, 10 months
[libvirt] pool-create/pool-create-as should include build pool then start?
by Zhimou Peng
Hi all,
According to https://bugzilla.redhat.com/show_bug.cgi?id=830056#c5, i think we should talk about this:
Description
If pool environment is not built, pool-create/pool-create-as will always fail.
I think pool-create should build the pool.
Version
qemu-kvm-0.12.1.2-2.295.el6.x86_64
kernel-2.6.32-276.el6.x86_64
libvirt-0.9.10-21.el6.x86_64
Steps
For example:
dir pool
virsh # pool-create dirpool.xml
error: Failed to create pool from dirpool.xml
error: cannot open path '/var/lib/libvirt/dir': No such file or directory
disk pool
virsh # pool-create diskpool.xml
error: Failed to create pool from diskpool.xml
error: internal error Child process (/usr/libexec/libvirt_parthelper /dev/sdb) status unexpected: exit status 2
fs pool
virsh # pool-create fspool.xml
error: Failed to create pool from fspool.xml
error: internal error Child process (/bin/mount -t ext4 /dev/sda7 /var/lib/libvirt/images/fspool) status unexpected: exit status 32
Steps are the same of other pools
12 years, 10 months
[libvirt] [PATCH 1/3] LXC: avoid useless memory free in lxcContainerIdentifyCGroups
by Gao feng
when lxcContainerIdentifyCGroups failed, lxcContainerSetupPivortRoot
and lxcContainerSetupExtraMounts will free the memory that allocated
in lxcContainerIdentifyCGroups.
So we need not call lxcContainerCGroupFree when
lxcContainerIdentifyCGroups failed.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 4fbceb4..87de463 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1236,17 +1236,16 @@ static int lxcContainerIdentifyCGroups(struct lxcContainerCGroup **mountsret,
}
}
- *mountsret = mounts;
- *nmountsret = nmounts;
ret = 0;
cleanup:
+ *mountsret = mounts;
+ *nmountsret = nmounts;
+
closedir(dh);
endmntent(procmnt);
VIR_FREE(path);
- if (ret < 0)
- lxcContainerCGroupFree(mounts, nmounts);
return ret;
}
--
1.7.7.6
12 years, 10 months
[libvirt] [PATCH] LXC: fix memory leak in lxcContainerGetSubtree
by Gao feng
when libvirt_lxc trigger oom error in lxcContainerGetSubtree
we should free the alloced memory for mounts.
so when lxcContainerGetSubtree failed,we should do some
memory cleanup in lxcContainerUnmountSubtree.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 5651255..633218c 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1118,10 +1118,11 @@ static int lxcContainerGetSubtree(const char *prefix,
virReportOOMError();
goto cleanup;
}
- if (!(mounts[nmounts++] = strdup(mntent.mnt_dir))) {
+ if (!(mounts[nmounts] = strdup(mntent.mnt_dir))) {
virReportOOMError();
goto cleanup;
}
+ nmounts++;
VIR_DEBUG("Grabbed %s", mntent.mnt_dir);
}
@@ -1129,11 +1130,10 @@ static int lxcContainerGetSubtree(const char *prefix,
qsort(mounts, nmounts, sizeof(mounts[0]),
lxcContainerChildMountSort);
- *mountsret = mounts;
- *nmountsret = nmounts;
ret = 0;
-
cleanup:
+ *mountsret = mounts;
+ *nmountsret = nmounts;
endmntent(procmnt);
return ret;
}
@@ -1151,7 +1151,7 @@ static int lxcContainerUnmountSubtree(const char *prefix,
VIR_DEBUG("Unmount subtreee from %s", prefix);
if (lxcContainerGetSubtree(prefix, &mounts, &nmounts) < 0)
- return -1;
+ goto cleanup;
for (i = 0 ; i < nmounts ; i++) {
VIR_DEBUG("Umount %s", mounts[i]);
if (umount(mounts[i]) < 0) {
--
1.7.7.6
12 years, 10 months
[libvirt] [PATCH 1/2] virsh: Tweak attach-* documentation
by Michal Privoznik
as we are missing:
attach-disk: --type can accept 'lun' too, not just cdrom or floppy.
attach-disk: --target specify logical device name, not path
attach-interface: --target silently drops strings with vnet* prefix
---
tools/virsh.pod | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 910a187..4729127 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1586,10 +1586,11 @@ needed if the device does not use managed mode.
[I<--multifunction>]
Attach a new disk device to the domain.
-I<source> and I<target> are paths for the files and devices.
-I<driver> can be I<file>, I<tap> or I<phy> for the Xen hypervisor depending on
-the kind of access; or I<qemu> for the QEMU emulator.
-I<type> can indicate I<cdrom> or I<floppy> as alternative to the disk default,
+I<source> is path for the files and devices. I<target> controls the bus or
+device under which the disk is exposed to the guest OS. It indicates the
+"logical" device name. I<driver> can be I<file>, I<tap> or I<phy> for the Xen
+hypervisor depending on the kind of access; or I<qemu> for the QEMU emulator.
+I<type> can indicate I<lun>, I<cdrom> or I<floppy> as alternative to the disk default,
although this use only replaces the media within the existing virtual cdrom or
floppy device; consider using B<update-device> for this usage instead.
I<mode> can specify the two specific mode I<readonly> or I<shareable>.
@@ -1614,7 +1615,8 @@ Attach a new network interface to the domain.
I<type> can be either I<network> to indicate a physical network device or
I<bridge> to indicate a bridge to a device.
I<source> indicates the source device.
-I<target> allows to indicate the target device in the guest.
+I<target> allows to indicate the target device in the guest. Names starting
+with 'vnet' are considered as auto-generated an hence blanked out.
I<mac> allows to specify the MAC address of the network interface.
I<script> allows to specify a path to a script handling a bridge instead of
the default one.
--
1.7.8.5
12 years, 10 months
[libvirt] [PATCH 1/2] qemu: don't bootup guest in reboot operation if the migration job is running
by Guannan Ren
After an reboot operation, the guest will shutdown first then bootup
in a separate thread from the eventloop thread. If we start the migration
job, according to the time gap between reboot and migrate command,
the system_reset action of bootup operation will probably block from the
migration job utill timeouts.
In this case, the solution is that we don't bootup the guest
on the source server, we pass the task to target machine.
---
src/qemu/qemu_process.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1df3637..7c7132a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -632,14 +632,14 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm)
{
struct qemud_driver *driver = qemu_driver;
- qemuDomainObjPrivatePtr priv;
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ struct qemuDomainJobObj *job = &priv->job;
virDomainEventPtr event = NULL;
VIR_DEBUG("vm=%p", vm);
virDomainObjLock(vm);
- priv = vm->privateData;
if (priv->gotShutdown) {
VIR_DEBUG("Ignoring repeated SHUTDOWN event from domain %s",
vm->def->name);
@@ -668,6 +668,17 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
if (priv->agent)
qemuAgentNotifyEvent(priv->agent, QEMU_AGENT_EVENT_SHUTDOWN);
+ /*
+ * When a vm is in the job of migrating out and meanwhile
+ * the guest is shutting down for an reboot, we keep the
+ * shutdown state of the vm on the source server, letting
+ * the target machine do the booting work after migration.
+ */
+ if (priv->fakeReboot &&
+ job->asyncJob &&
+ job->asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT)
+ goto unlock;
+
qemuProcessShutdownOrReboot(driver, vm);
unlock:
--
1.7.7.5
12 years, 10 months
[libvirt] [PATCH] LXC: fix memory leak in lxcContainerMountFSBlockHelper
by Gao feng
we alloc the memory for format in lxcContainerMountDetectFilesystem
but without free it in lxcContainerMountFSBlockHelper.
this patch just call VIR_FREE to free it.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 297bd6d..5651255 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1014,6 +1014,7 @@ static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs,
}
cleanup:
+ VIR_FREE(format);
return ret;
}
--
1.7.7.6
12 years, 10 months
[libvirt] [PATCH v2] virsh: Update vol-create-as manpage
by Michal Privoznik
as we support qed format as well.
---
docs/schemas/storagevol.rng | 1 +
tools/virsh.c | 2 +-
tools/virsh.pod | 5 +++--
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 8edb877..7a74331 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -153,6 +153,7 @@
<value>iso</value>
<value>qcow</value>
<value>qcow2</value>
+ <value>qed</value>
<value>vmdk</value>
<value>vpc</value>
</choice>
diff --git a/tools/virsh.c b/tools/virsh.c
index 4d34d49..1e1de39 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -11351,7 +11351,7 @@ static const vshCmdOptDef opts_vol_create_as[] = {
{"allocation", VSH_OT_STRING, 0,
N_("initial allocation size, as scaled integer (default bytes)")},
{"format", VSH_OT_STRING, 0,
- N_("file format type raw,bochs,qcow,qcow2,vmdk")},
+ N_("file format type raw,bochs,qcow,qcow2,qed,vmdk")},
{"backing-vol", VSH_OT_STRING, 0,
N_("the backing volume if taking a snapshot")},
{"backing-vol-format", VSH_OT_STRING, 0,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 4729127..1a6bef2 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2163,11 +2163,12 @@ I<capacity> is the size of the volume to be created, as a scaled integer
I<--allocation> I<size> is the initial size to be allocated in the volume,
also as a scaled integer defaulting to bytes.
I<--format> I<string> is used in file based storage pools to specify the volume
-file format to use; raw, bochs, qcow, qcow2, vmdk.
+file format to use; raw, bochs, qcow, qcow2, vmdk, qed.
I<--backing-vol> I<vol-name-or-key-or-path> is the source backing
volume to be used if taking a snapshot of an existing volume.
I<--backing-vol-format> I<string> is the format of the snapshot backing volume;
-raw, bochs, qcow, qcow2, vmdk, host_device.
+raw, bochs, qcow, qcow2, qed, vmdk, host_device. These are, however, meant for
+file based storage pools.
=item B<vol-clone> [I<--pool> I<pool-or-uuid>] I<vol-name-or-key-or-path>
I<name>
--
1.7.8.5
12 years, 10 months