[libvirt] [PATCH 0/3] Support --allocate and --shrink for vol-resize
by Osier Yang
https://bugzilla.redhat.com/show_bug.cgi?id=804516
Though the bug's title is about the document, but I prefer to implement
it instead of changing document. Those two flags were added long time
ago, but never implemented, it's not good to say they are not supported
now while they were already exposed outside.
A few examples of vol-resize with the patches:
1) Create 5M a parse vol
% dd of=/var/lib/libvirt/images/sparse.raw bs=1k seek=5120 count=0
0+0 records in
0+0 records out
0 bytes (0 B) copied, 7.904e-06 s, 0.0 kB/s
% ./tools/virsh pool-refresh default
Pool default refreshed
%s ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name: sparse.raw
Type: file
Capacity: 5.00 MiB
Allocation: 0.00 B
2) Resize the vol to 6M with --allocate, I.E. The capacity (5M - 6M) is
preallocated.
% ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 6M --allocate
Size of volume 'sparse.raw' successfully changed to 6M
% ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name: sparse.raw
Type: file
Capacity: 6.00 MiB
Allocation: 1.00 MiB
3) Resize the vol to 7M without --allocate. I.E. The new 1M capacity
(6M - 7M) is sparse.
% ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 7M
Size of volume 'sparse.raw' successfully changed to 7M
%s ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name: sparse.raw
Type: file
Capacity: 7.00 MiB
Allocation: 1.00 MiB
3) Resize the vol to 8M with --allocate, I.E. The new 1 M capacity
(7M - 8M) is preallocated
% ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 8M --allocate
Size of volume 'sparse.raw' successfully changed to 8M
% ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name: sparse.raw
Type: file
Capacity: 8.00 MiB
Allocation: 2.00 MiB
======
Now the parse file's allocation is like:
0 5 6 7 8
-----------------------------------------------------------------
| zero | allocated | zero | allocated |
-----------------------------------------------------------------
%s ./tools/virsh vol-resize /var/lib/libvirt/images/sparse.raw 6M --shrink
Size of volume 'sparse.raw' successfully changed to 6M
%s ./tools/virsh vol-info /var/lib/libvirt/images/sparse.raw
Name: sparse.raw
Type: file
Capacity: 6.00 MiB
Allocation: 1.00 MiB
=====
The vol still get 1M preallocate space kept, expected.
Osier Yang (3):
storage: Support preallocate the new capacity for vol-resize
storage: Forbid to shrink the vol's capacity if no --shrink is
specified
storage: Allow --shrink for raw type volume of fs pool
src/storage/storage_backend_fs.c | 22 ++++++++++++++++++----
src/storage/storage_driver.c | 12 +++++++++++-
src/util/virstoragefile.c | 39 ++++++++++++++++++++++++++++++++++++---
src/util/virstoragefile.h | 6 +++++-
4 files changed, 70 insertions(+), 9 deletions(-)
--
1.8.1.4
11 years, 11 months
[libvirt] [PATCH] virtlockd: fix socket path
by Ján Tomko
Change the socket path to match the one used by lockd driver.
https://bugzilla.redhat.com/show_bug.cgi?id=968128
---
src/locking/virtlockd.socket.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/locking/virtlockd.socket.in b/src/locking/virtlockd.socket.in
index a6eef4f..a38b1f4 100644
--- a/src/locking/virtlockd.socket.in
+++ b/src/locking/virtlockd.socket.in
@@ -2,7 +2,7 @@
Description=Virtual machine lock manager socket
[Socket]
-ListenStream=@localstatedir(a)/run/libvirt/virtlockd/virtlockd.sock
+ListenStream=@localstatedir@/run/libvirt/virtlockd-sock
[Install]
WantedBy=multi-user.target
--
1.8.1.5
11 years, 11 months
[libvirt] [PATCH] snapshot: remove mutually exclusive memory and disk-only duplicate check
by Guannan Ren
The work was done at the time of snapshot xmlstring parsing
if (offline && def->memory &&
def->memory != VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) {
virReportError(...);
}
---
src/qemu/qemu_driver.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9d3f632..db56823 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11730,14 +11730,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
"with external checkpoints"));
goto cleanup;
}
- if ((def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL ||
- def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL) &&
- flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY) {
- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("disk-only snapshot creation is not compatible with "
- "memory snapshot"));
- goto cleanup;
- }
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE) {
/* Prevent circular chains */
--
1.8.1.4
11 years, 11 months
[libvirt] [PATCH] Ensure non-root can read /proc/meminfo file in LXC containers
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
By default files in a FUSE mount can only be accessed by the
user which created them, even if the file permissions would
otherwise allow it. To allow other users to access the FUSE
mount the 'allow_other' mount option must be used. This bug
prevented non-root users in an LXC container from reading
the /proc/meminfo file.
https://bugzilla.redhat.com/show_bug.cgi?id=967977
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_fuse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index b6df99c..32886cd 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -307,6 +307,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
/* process name is libvirt_lxc */
if (fuse_opt_add_arg(&args, "libvirt_lxc") == -1 ||
fuse_opt_add_arg(&args, "-odirect_io") == -1 ||
+ fuse_opt_add_arg(&args, "-oallow_other") == -1 ||
fuse_opt_add_arg(&args, "-ofsname=libvirt") == -1)
goto cleanup1;
--
1.8.1.4
11 years, 11 months
[libvirt] [PATCH v2] nwfilter: grab driver lock earlier during init (bz96649)
by Stefan Berger
This patch is in _relation_ to Bug 966449:
https://bugzilla.redhat.com/show_bug.cgi?id=966449
Below is a possible patch addressing the coredump.
Thread 1 must be calling nwfilterDriverRemoveDBusMatches(). It does so with
nwfilterDriverLock held. In the patch below I am now moving the
nwfilterDriverLock(driverState) further up so that the initialization, which
seems to either take a long time or is entirely stuck, occurs with the lock
held and the shutdown cannot occur at the same time.
Remove the lock in virNWFilterDriverIsWatchingFirewallD to avoid trying to
lock the same lock again.
---
src/nwfilter/nwfilter_driver.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
Index: libvirt/src/nwfilter/nwfilter_driver.c
===================================================================
--- libvirt.orig/src/nwfilter/nwfilter_driver.c
+++ libvirt/src/nwfilter/nwfilter_driver.c
@@ -191,6 +191,8 @@ nwfilterStateInitialize(bool privileged,
if (!privileged)
return 0;
+ nwfilterDriverLock(driverState);
+
if (virNWFilterIPAddrMapInit() < 0)
goto err_free_driverstate;
if (virNWFilterLearnInit() < 0)
@@ -203,8 +205,6 @@ nwfilterStateInitialize(bool privileged,
if (virNWFilterConfLayerInit(virNWFilterDomainFWUpdateCB) < 0)
goto err_techdrivers_shutdown;
- nwfilterDriverLock(driverState);
-
/*
* startup the DBus late so we don't get a reload signal while
* initializing
@@ -316,16 +316,10 @@ nwfilterStateReload(void) {
bool
virNWFilterDriverIsWatchingFirewallD(void)
{
- bool ret;
-
if (!driverState)
return false;
- nwfilterDriverLock(driverState);
- ret = driverState->watchingFirewallD;
- nwfilterDriverUnlock(driverState);
-
- return ret;
+ return driverState->watchingFirewallD;
}
/**
11 years, 11 months
[libvirt] [PATCH] Ensure non-root can read /proc/meminfo file in LXC containers
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
By default files in a FUSE mount can only be accessed by the
user which created them, even if the file permissions would
otherwise allow it. To allow other users to access the FUSE
mount the 'allow_other' mount option must be used. This bug
prevented non-root users in an LXC container from reading
the /proc/meminfo file.
https://bugzilla.redhat.com/show_bug.cgi?id=967977
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_fuse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index b6df99c..32886cd 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -307,6 +307,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
/* process name is libvirt_lxc */
if (fuse_opt_add_arg(&args, "libvirt_lxc") == -1 ||
fuse_opt_add_arg(&args, "-odirect_io") == -1 ||
+ fuse_opt_add_arg(&args, "-oallow_other") == -1 ||
fuse_opt_add_arg(&args, "-ofsname=libvirt") == -1)
goto cleanup1;
--
1.8.1.4
11 years, 11 months
[libvirt] [PATCH] docs: add spaces to formatstorage.html
by Ján Tomko
Let the pool types breathe.
---
Trivial.
docs/formatstorage.html.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 9c3be67..1a45915 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -17,9 +17,9 @@
<p>
The top level tag for a storage pool document is 'pool'. It has
a single attribute <code>type</code>, which is one of <code>dir</code>,
- <code>fs</code>,<code>netfs</code>,<code>disk</code>,<code>iscsi</code>,
- <code>logical</code>. This corresponds to the storage backend drivers
- listed further along in this document.
+ <code>fs</code>, <code>netfs</code>, <code>disk</code>,
+ <code>iscsi</code>, <code>logical</code>. This corresponds to the
+ storage backend drivers listed further along in this document.
The storage pool XML format is available <span class="since">since 0.4.1</span>
</p>
<h3><a name="StoragePoolFirst">General metadata</a></h3>
--
1.8.1.5
11 years, 11 months
[libvirt] [PATCH] qemu: Report the offset from host UTC for RTC_CHANGE event
by Osier Yang
https://bugzilla.redhat.com/show_bug.cgi?id=964177
Though both libvirt and QEMU's document say RTC_CHANGE returns
the offset from the host UTC, qemu actually returns the offset
from the specified date instead when specific date is privided
(-rtc base=$date).
It's not safe for qemu to fix it in code, it worked like that
for 3 years, changing it now may break other QEMU use cases.
What qemu tries to do is to fix the document:
http://lists.gnu.org/archive/html/qemu-devel/2013-05/msg04782.html
And in libvirt side, instead of reply on the qemu, this covert
the offset returned from qemu to the offset from host UTC, by:
/*
* a: the offset from qemu RTC_CHANGE event
* b: The specified date (-rtc base=$date)
* c: the host date when libvirt gets the RTC_CHANGE event
* offset: What libvirt will report
*/
offset = a + (b - c);
The specified date (-rtc base=$date) is recorded in clock's def as
an internal only member (may be useful to exposed outside?).
---
src/conf/domain_conf.h | 3 +++
src/qemu/qemu_command.c | 3 +++
src/qemu/qemu_process.c | 12 ++++++++++++
3 files changed, 18 insertions(+)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3a71d6c..3947a56 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1767,6 +1767,9 @@ struct _virDomainClockDef {
struct {
long long adjustment;
int basis;
+
+ /* Store the start time of guest process, internaly only */
+ time_t starttime;
} variable;
/* Timezone name, when
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c4a162a..9254525 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5518,6 +5518,9 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
now += def->data.variable.adjustment;
gmtime_r(&now, &nowbits);
+ /* Store the starttime of qemu process */
+ def->data.variable.starttime = now;
+
virBufferAsprintf(&buf, "base=%d-%02d-%02dT%02d:%02d:%02d",
nowbits.tm_year + 1900,
nowbits.tm_mon + 1,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d4fd4fb..e6f0b6d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -796,6 +796,18 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virObjectLock(vm);
+
+ /* QEMU's RTC_CHANGE event returns the offset from the specified
+ * date instead of the host UTC if a specific date is provided
+ * (-rtc base=$date). We need to convert it to be offset from
+ * host UTC.
+ */
+ if (vm->def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE) {
+ time_t now = time(NULL);
+
+ offset += vm->def->clock.data.variable.starttime - now;
+ }
+
event = virDomainEventRTCChangeNewFromObj(vm, offset);
if (vm->def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE)
--
1.8.1.4
11 years, 11 months
[libvirt] [PATCH] Remove legacy code for single-instance devpts filesystem
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
An earlier commit dropped support for using LXC with kernels
having single-instance devpts filesystem from the LXC
controller. It forgot to remove the same code from the LXC
container setup.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_container.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index c74e3ca..181f6c8 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -869,25 +869,14 @@ static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
}
}
- if (access("/dev/pts/ptmx", W_OK) == 0) {
- /* We have private devpts capability, so bind that */
- if (virFileTouch("/dev/ptmx", 0666) < 0)
- return -1;
+ /* We have private devpts capability, so bind that */
+ if (virFileTouch("/dev/ptmx", 0666) < 0)
+ return -1;
- if (mount("/dev/pts/ptmx", "/dev/ptmx", "ptmx", MS_BIND, NULL) < 0) {
- virReportSystemError(errno, "%s",
- _("Failed to bind /dev/pts/ptmx on to /dev/ptmx"));
- return -1;
- }
- } else {
- /* Legacy devpts, so we need to just use shared one */
- dev_t dev = makedev(LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX);
- if (mknod("/dev/ptmx", S_IFCHR, dev) < 0 ||
- chmod("/dev/ptmx", 0666)) {
- virReportSystemError(errno, "%s",
- _("Failed to make device /dev/ptmx"));
- return -1;
- }
+ if (mount("/dev/pts/ptmx", "/dev/ptmx", "ptmx", MS_BIND, NULL) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Failed to bind /dev/pts/ptmx on to /dev/ptmx"));
+ return -1;
}
for (i = 0; i < nttyPaths; i++) {
--
1.8.1.4
11 years, 11 months