[libvirt] [PATCH] virsh: report 0-length active block-commit job status
by Eric Blake
At least with live block commit, it is possible to have a block
job that reports 0 status: namely, when the active image contains
no sectors that differ from the backing image it is being committed
into [1]. I'm not sure if that represents a qemu bug, but it leads
to weird virsh output where 'virsh blockjob $dom vda' has no output
during a no-op commit job. It appears that the special case for
a zero total was first introduced for migration, where it does sort
of make sense (when we do storage migration, the job is broken up
into two pieces where the first half of migrating storage has no
clue what the total length of the second phase will be, and where
qemu migration always reports a non-zero total length but only once
we complete the first phase to start actual migration), but it
doesn't seem to make sense for any of the block jobs.
[1] https://www.redhat.com/archives/libvir-list/2015-January/msg00348.html
* tools/virsh-domain.c (vshPrintJobProgress): Move special-case of
0 total...
(vshWatchJob): ...into lone caller where it matters.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
tools/virsh-domain.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6733cfa..ec62aae 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1,7 +1,7 @@
/*
* virsh-domain.c: Commands to manage domain
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1678,10 +1678,6 @@ vshPrintJobProgress(const char *label, unsigned long long remaining,
{
int progress;
- if (total == 0)
- /* migration has not been started */
- return;
-
if (remaining == 0) {
/* migration has completed */
progress = 100;
@@ -4189,7 +4185,7 @@ vshWatchJob(vshControl *ctl,
ret = virDomainGetJobInfo(dom, &jobinfo);
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
if (ret == 0) {
- if (verbose)
+ if (verbose && jobinfo.dataTotal)
vshPrintJobProgress(label, jobinfo.dataRemaining,
jobinfo.dataTotal);
--
2.1.0
10 years, 3 months
[libvirt] Looking for Outreachy sponsors for QEMU, libvirt, and KVM internships (was Outreach Program for Women)
by Stefan Hajnoczi
Outreach Program for Women is renaming to Outreachy. The new website
is: http://outreachy.org/
What is Outreachy?
Outreachy helps people from underrepresented groups join the open
source community
through a 12-week full-time paid internship.
The format is similar to Google Summer of Code. Instead of funding
university students
the focus is on funding women (cis and trans), trans men, and
genderqueer people.
Last year QEMU participated with one intern, Maria, who developed a
qcow2 image format
fuzzer to find input validation bugs in QEMU's qcow2 block driver.
GNOME, the Linux kernel community, and other projects have also been
participating
successfully for years.
What is the level of sponsorship?
Sponsorship is $6,500 per intern. Sponsors can choose their mentor if desired,
otherwise we have experienced mentors who can participate.
If your company wants to be active in growing the open source
community, this is a
great way to engage without administrating your own internship program!
Dates:
* Funding commitment: Monday, February 16
* Participating orgs announced: February 17
* Application deadline for interns: March 24
* Internship dates: May 25 to August 25
Sponsors are listed for recognition on the Outreachy website and can
promote job openings.
How do QEMU, libvirt, and KVM participate?
We try to participate in both Outreachy and Google Summer of Code each
year. QEMU acts
as an umbrella organization for libvirt and KVM. We have experienced
mentors and are able
to add new mentors who are active contributors to QEMU, libvirt, or KVM.
Full info for organizations:
https://wiki.gnome.org/Outreachy/Admin/InfoForOrgs
Please let me know if you have any questions.
Stefan
10 years, 3 months
[libvirt] [PATCH 0/8] qemu: support setting device's boot order when VM is running
by Wang Rui
QEMU supported to set device's boot index online recently(since QEMU 2.2.0).
http://lists.gnu.org/archive/html/qemu-devel/2014-10/msg00879.html
The QMP "qom-set" is available for setting boot index. qom-set's example is as follows:
{
.name = "qom-set",
.args_type = "path:s,property:s,value:q",
.mhandler.cmd_new = qmp_qom_set,
}
(qemu) qom-set nic1 bootindex 3
(qemu) qom-set nic1 bootindex -1
(qemu) qom-set scsi0-0-0-0 bootindex 2
Setting boot index to -1 means cancel it.
We can attach/update a device and set it's boot order when VM is running. The boot
order will take effect immediately(after guest rebooting). For example, we can use
'virsh update-device' to change an interface's boot order. The xml is specified as
below.
<interface type='bridge'>
<mac address='fa:16:3e:2e:d4:3d'/>
<source bridge='br0'/>
<target dev='tap4f2bce78-5b'/>
<model type='virtio'/>
<driver queues='4'/>
<boot order='2'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
If the 'boot order' is not specified in the xml, that means canceling its boot order.
Wang Rui (8):
qemu: add a new qemuMonitorSetBootIndex() method to set device's
bootorder
qemu: support attachment of net device with boot index
conf: check boot order which is used by itself
qemu: a code movement
qemu: support attachment of disk device with boot index
conf: add compatiblity check for boot index when updating device
qemu: support updating interface with boot index
qemu: support updating disk with boot index
src/conf/device_conf.c | 13 ++
src/conf/device_conf.h | 12 ++
src/conf/domain_conf.c | 74 ++++++----
src/conf/domain_conf.h | 9 --
src/qemu/qemu_driver.c | 64 +++++++--
src/qemu/qemu_hotplug.c | 329 +++++++++++++++++++++++++++++++------------
src/qemu/qemu_hotplug.h | 4 +
src/qemu/qemu_monitor.c | 25 ++++
src/qemu/qemu_monitor.h | 4 +
src/qemu/qemu_monitor_json.c | 19 +++
src/qemu/qemu_monitor_json.h | 5 +
11 files changed, 424 insertions(+), 134 deletions(-)
--
1.7.12.4
10 years, 3 months
[libvirt] [PATCH] virsh-volume: add support for --reflink
by Chen Hanxiao
add support for --reflink to specify
VIR_STORAGE_VOL_CREATE_REFLINK flag.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
tools/virsh-volume.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index d585ee2..db94154 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -204,6 +204,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false;
@@ -378,6 +379,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false;
@@ -441,6 +443,10 @@ static const vshCmdOptDef opts_vol_create_from[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "reflink",
+ .type = VSH_OT_BOOL,
+ .help = N_("use btrfs COW lightweight copy")
+ },
{.name = NULL}
};
@@ -460,6 +466,9 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+ if (vshCommandOptBool(cmd, "reflink"))
+ flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
+
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
goto cleanup;
@@ -554,6 +563,10 @@ static const vshCmdOptDef opts_vol_clone[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "reflink",
+ .type = VSH_OT_BOOL,
+ .help = N_("use btrfs COW lightweight copy")
+ },
{.name = NULL}
};
@@ -574,6 +587,9 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+ if (vshCommandOptBool(cmd, "reflink"))
+ flags |= VIR_STORAGE_VOL_CREATE_REFLINK;
+
origpool = virStoragePoolLookupByVolume(origvol);
if (!origpool) {
vshError(ctl, "%s", _("failed to get parent pool"));
--
2.1.0
10 years, 3 months
[libvirt] [PATCH v2] Make tests independant of system page size
by Daniel P. Berrange
Some code paths have special logic depending on the page size
reported by sysconf, which in turn affects the test results.
We must mock this so tests always have a consistent page size.
---
cfg.mk | 8 ++++++++
src/libvirt_private.syms | 2 ++
src/openvz/openvz_util.c | 5 +----
src/qemu/qemu_command.c | 6 +++---
src/qemu/qemu_driver.c | 6 +-----
src/util/virfile.c | 2 +-
src/util/virnuma.c | 6 +++---
src/util/virutil.c | 13 +++++++++++++
src/util/virutil.h | 3 +++
src/xen/xen_hypervisor.c | 4 ++--
tests/qemuxml2argvmock.c | 8 ++++++++
tests/qemuxml2argvtest.c | 1 +
12 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 70612f8..d72b039 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -997,6 +997,11 @@ sc_prohibit_virXXXFree:
halt='avoid using 'virXXXFree', use 'virObjectUnref' instead' \
$(_sc_search_regexp)
+sc_prohibit_sysconf_pagesize:
+ @prohibit='sysconf\(_SC_PAGESIZE' \
+ halt='use virGetSystemPageSize[KB] instead of sysconf(_SC_PAGESIZE)' \
+ $(_sc_search_regexp)
+
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
@@ -1187,3 +1192,6 @@ exclude_file_name_regexp--sc_prohibit_devname = \
exclude_file_name_regexp--sc_prohibit_virXXXFree = \
^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).c$$)
+
+exclude_file_name_regexp--sc_prohibit_sysconf_pagesize = \
+ ^(cfg\.mk|src/util/virutil\.c)$$
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f7f8ea2..376c69b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2228,6 +2228,8 @@ virGetListenFDs;
virGetSCSIHostNameByParentaddr;
virGetSCSIHostNumber;
virGetSelfLastChanged;
+virGetSystemPageSize;
+virGetSystemPageSizeKB;
virGetUnprivSGIOSysfsPath;
virGetUserCacheDirectory;
virGetUserConfigDirectory;
diff --git a/src/openvz/openvz_util.c b/src/openvz/openvz_util.c
index 8032f6a..3cdc1c2 100644
--- a/src/openvz/openvz_util.c
+++ b/src/openvz/openvz_util.c
@@ -42,10 +42,7 @@ openvzKBPerPages(void)
static long kb_per_pages;
if (kb_per_pages == 0) {
- kb_per_pages = sysconf(_SC_PAGESIZE);
- if (kb_per_pages > 0) {
- kb_per_pages /= 1024;
- } else {
+ if ((kb_per_pages = virGetSystemPageSizeKB()) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Can't determine page size"));
kb_per_pages = 0;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ec4f35b..3b6eddc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4540,7 +4540,7 @@ qemuBuildMemoryBackendStr(unsigned long long size,
virDomainHugePagePtr master_hugepage = NULL;
virDomainHugePagePtr hugepage = NULL;
virDomainNumatuneMemMode mode;
- const long system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ const long system_page_size = virGetSystemPageSizeKB();
virMemAccess memAccess = def->cpu->cells[guestNode].memAccess;
size_t i;
char *mem_path = NULL;
@@ -7051,7 +7051,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
bool needBackend = false;
int rc;
int ret = -1;
- const long system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ const long system_page_size = virGetSystemPageSizeKB();
if (virDomainNumatuneHasPerNodeBinding(def->numatune) &&
!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
@@ -8239,7 +8239,7 @@ qemuBuildCommandLine(virConnectPtr conn,
def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
if (def->mem.nhugepages && (!def->cpu || !def->cpu->ncells)) {
- const long system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ const long system_page_size = virGetSystemPageSizeKB();
char *mem_path = NULL;
if (def->mem.hugepages[0].size == system_page_size) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 59a9593..cf351e6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1352,12 +1352,8 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
if (lastCpu)
*lastCpu = cpu;
- /* We got pages
- * We want kiloBytes
- * _SC_PAGESIZE is page size in Bytes
- * So calculate, but first lower the pagesize so we don't get overflow */
if (vm_rss)
- *vm_rss = rss * (sysconf(_SC_PAGESIZE) >> 10);
+ *vm_rss = rss * virGetSystemPageSizeKB();
VIR_DEBUG("Got status for %d/%d user=%llu sys=%llu cpu=%d rss=%ld",
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 4024f3d..68ef6eb 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1086,7 +1086,7 @@ safezero_mmap(int fd, off_t offset, off_t len)
/* align offset and length, rounding offset down and length up */
if (pagemask == 0)
- pagemask = ~(sysconf(_SC_PAGESIZE) - 1);
+ pagemask = ~(virGetSystemPageSize() - 1);
map_skip = offset - (offset & pagemask);
/* memset wants the mmap'ed file to be present on disk so create a
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 86564d4..e986c71 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -639,7 +639,7 @@ virNumaGetPageInfo(int node,
unsigned int *page_free)
{
int ret = -1;
- long system_page_size = sysconf(_SC_PAGESIZE);
+ long system_page_size = virGetSystemPageSize();
/* sysconf() returns page size in bytes,
* the @page_size is however in kibibytes */
@@ -717,7 +717,7 @@ virNumaGetPages(int node,
/* sysconf() returns page size in bytes,
* but we are storing the page size in kibibytes. */
- system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ system_page_size = virGetSystemPageSizeKB();
/* Query huge pages at first.
* On Linux systems, the huge pages pool cuts off the available memory and
@@ -841,7 +841,7 @@ virNumaSetPagePoolSize(int node,
char *end;
unsigned long long nr_count;
- if (page_size == sysconf(_SC_PAGESIZE) / 1024) {
+ if (page_size == virGetSystemPageSizeKB()) {
/* Special case as kernel handles system pages
* differently to huge pages. */
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 3037293..c905209 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2577,3 +2577,16 @@ virGetListenFDs(void)
}
#endif /* WIN32 */
+
+long virGetSystemPageSize(void)
+{
+ return sysconf(_SC_PAGESIZE);
+}
+
+long virGetSystemPageSizeKB(void)
+{
+ long val = virGetSystemPageSize();
+ if (val < 0)
+ return val;
+ return val / 1024;
+}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index f31bf88..d1173c1 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -244,4 +244,7 @@ VIR_ENUM_DECL(virTristateSwitch)
unsigned int virGetListenFDs(void);
+long virGetSystemPageSize(void);
+long virGetSystemPageSizeKB(void);
+
#endif /* __VIR_UTIL_H__ */
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 2473532..31a2a1b 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2736,7 +2736,7 @@ xenHypervisorGetMaxMemory(virConnectPtr conn,
int ret;
if (kb_per_pages == 0) {
- kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
+ kb_per_pages = virGetSystemPageSizeKB();
if (kb_per_pages <= 0)
kb_per_pages = 4;
}
@@ -2771,7 +2771,7 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
uint32_t domain_flags, domain_state, domain_shutdown_cause;
if (kb_per_pages == 0) {
- kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
+ kb_per_pages = virGetSystemPageSizeKB();
if (kb_per_pages <= 0)
kb_per_pages = 4;
}
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index eccf4b0..d24725e 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -22,7 +22,15 @@
#include "internal.h"
#include "virnuma.h"
+#include "virmock.h"
+#include "virutil.h"
#include <time.h>
+#include <unistd.h>
+
+long virGetSystemPageSize(void)
+{
+ return 4096;
+}
time_t time(time_t *t)
{
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 89afa81..77ee630 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -22,6 +22,7 @@
# include "cpu/cpu_map.h"
# include "virstring.h"
# include "storage/storage_driver.h"
+# include "virmock.h"
# include "testutilsqemu.h"
--
2.1.0
10 years, 3 months
[libvirt] [PATCH] virnetdev: fix some issues found by coverity and mingw builds
by Pavel Hrdina
Commit e562a61a introduced new function to get/set interface state but
there was misuse of ATTRIBUTE_NONNULL on non-pointer attributes and also
we need to wrap that functions by #ifdef to not break mingw build.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/virnetdev.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++--
src/util/virnetdev.h | 12 +++----
2 files changed, 96 insertions(+), 10 deletions(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 7a0a43d..d8a4867 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -671,12 +671,23 @@ int virNetDevSetIFFlag(const char *ifname,
*
* Returns 0 in case of success or -1 on error.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevSetOnline(const char *ifname,
bool online)
{
return virNetDevSetIFFlag(ifname, IFF_UP, online);
}
+#else
+int virNetDevSetOnline(const char *ifname,
+ bool online ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot set interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
* virNetDevSetPromiscuous:
@@ -689,11 +700,22 @@ int virNetDevSetOnline(const char *ifname,
*
* Returns 0 in case of success or -1 on error.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevSetPromiscuous(const char *ifname,
bool promiscuous)
{
return virNetDevSetIFFlag(ifname, IFF_PROMISC, promiscuous);
}
+#else
+int virNetDevSetPromiscuous(const char *ifname,
+ bool promiscuous ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot set interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
* virNetDevSetRcvMulti:
@@ -707,11 +729,22 @@ int virNetDevSetPromiscuous(const char *ifname,
*
* Returns 0 in case of success or -1 on error.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevSetRcvMulti(const char *ifname,
bool receive)
{
return virNetDevSetIFFlag(ifname, IFF_MULTICAST, receive);
}
+#else
+int virNetDevSetRcvMulti(const char *ifname,
+ bool receive ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot set interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
* virNetDevSetRcvAllMulti:
@@ -723,11 +756,22 @@ int virNetDevSetRcvMulti(const char *ifname,
*
* Returns 0 in case of success or -1 on error.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevSetRcvAllMulti(const char *ifname,
bool receive)
{
return virNetDevSetIFFlag(ifname, IFF_ALLMULTI, receive);
}
+#else
+int virNetDevSetRcvAllMulti(const char *ifname,
+ bool receive ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot set interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
#if defined(SIOCGIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
@@ -776,11 +820,22 @@ int virNetDevGetIFFlag(const char *ifname,
*
* Returns 0 in case of success or an errno code in case of failure.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevGetOnline(const char *ifname,
bool *online)
{
return virNetDevGetIFFlag(ifname, IFF_UP, online);
}
+#else
+int virNetDevGetOnline(const char *ifname,
+ bool *online ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot get interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
* virNetDevIsPromiscuous:
@@ -792,11 +847,22 @@ int virNetDevGetOnline(const char *ifname,
*
* Returns 0 in case of success or an errno code in case of failure.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevGetPromiscuous(const char *ifname,
- bool *promiscuous)
+ bool *promiscuous)
{
return virNetDevGetIFFlag(ifname, IFF_PROMISC, promiscuous);
}
+#else
+int virNetDevGetPromiscuous(const char *ifname,
+ bool *promiscuous ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot get interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
* virNetDevIsRcvMulti:
@@ -808,11 +874,22 @@ int virNetDevGetPromiscuous(const char *ifname,
*
* Returns 0 in case of success or -1 on error.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevGetRcvMulti(const char *ifname,
- bool *receive)
+ bool *receive)
{
return virNetDevGetIFFlag(ifname, IFF_MULTICAST, receive);
}
+#else
+int virNetDevGetRcvMulti(const char *ifname,
+ bool *receive ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot get interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
* virNetDevIsRcvAllMulti:
@@ -824,11 +901,22 @@ int virNetDevGetRcvMulti(const char *ifname,
*
* Returns 0 in case of success or -1 on error.
*/
+#if defined(SIOCSIFFLAGS) && defined(HAVE_STRUCT_IFREQ)
int virNetDevGetRcvAllMulti(const char *ifname,
- bool *receive)
+ bool *receive)
{
return virNetDevGetIFFlag(ifname, IFF_ALLMULTI, receive);
}
+#else
+int virNetDevGetRcvAllMulti(const char *ifname,
+ bool *receive ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS,
+ _("Cannot get interface flags on '%s'"),
+ ifname);
+ return -1;
+}
+#endif
/**
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 8d03459..1001e43 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -201,25 +201,23 @@ int virNetDevDelMulti(const char *ifname,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virNetDevSetIFFlag(const char *ifname, int flag, bool val)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
- ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevGetIFFlag(const char *ifname, int flag, bool *val)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
- ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
int virNetDevSetPromiscuous(const char *ifname, bool promiscuous)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevGetPromiscuous(const char *ifname, bool *promiscuous)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virNetDevSetRcvMulti(const char *ifname, bool receive)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevGetRcvMulti(const char *ifname, bool *receive)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virNetDevSetRcvAllMulti(const char *ifname, bool receive)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevGetRcvAllMulti(const char *ifname, bool *receive)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
#endif /* __VIR_NETDEV_H__ */
--
2.0.5
10 years, 3 months
[libvirt] Missing libxl_device_nic settings
by Kim Larry
Hi,
I was trying to pass ip address to scripts/vif-bridge by putting <ip address=""/> in guest config xml file, however, I found that libxlMakeNic(which located in libxl/libxl_conf.c:956) doesn't set x_nic->ip. So I patched myself but I'm not so sure about VIR_DOMAIN_NET_TYPE_ETHERNET. It seems like vif-route, correct?
Here is my patch:
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 0555b91..0effc59 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1047,10 +1047,18 @@ libxlMakeNic(virDomainDefPtr def,
if (VIR_STRDUP(x_nic->bridge,
virDomainNetGetActualBridgeName(l_nic)) < 0)
return -1;
- /* fallthrough */
+ if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
+ return -1;
+ if (VIR_STRDUP(x_nic->ip, l_nic->data.bridge.ipaddr) < 0)
+ return -1;
+ break;
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (VIR_STRDUP(x_nic->script, l_nic->script) < 0)
return -1;
+ if (VIR_STRDUP(x_nic->ip, l_nic->data.ethernet.ipaddr) < 0)
+ return -1;
+ if (VIR_STRDUP(x_nic->gatewaydev, l_nic->data.ethernet.dev) < 0)
+ return -1;
break;
case VIR_DOMAIN_NET_TYPE_NETWORK:
{
Regards,
Jihoon
10 years, 3 months
[libvirt] [PATCH] Make tests independant of system page size
by Daniel P. Berrange
Some code paths have special logic depending on the page size
reported by sysconf, which in turn affects the test results.
We must mock this so tests always have a consistent page size.
---
src/libvirt_private.syms | 2 ++
src/openvz/openvz_util.c | 5 +----
src/qemu/qemu_command.c | 4 ++--
src/qemu/qemu_driver.c | 6 +-----
src/util/virfile.c | 2 +-
src/util/virnuma.c | 6 +++---
src/util/virutil.c | 13 +++++++++++++
src/util/virutil.h | 3 +++
src/xen/xen_hypervisor.c | 4 ++--
tests/qemuxml2argvmock.c | 13 +++++++++++++
tests/qemuxml2argvtest.c | 1 +
11 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index bd7870f..aa68797 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2215,6 +2215,8 @@ virGetListenFDs;
virGetSCSIHostNameByParentaddr;
virGetSCSIHostNumber;
virGetSelfLastChanged;
+virGetSystemPageSize;
+virGetSystemPageSizeKB;
virGetUnprivSGIOSysfsPath;
virGetUserCacheDirectory;
virGetUserConfigDirectory;
diff --git a/src/openvz/openvz_util.c b/src/openvz/openvz_util.c
index 8032f6a..3cdc1c2 100644
--- a/src/openvz/openvz_util.c
+++ b/src/openvz/openvz_util.c
@@ -42,10 +42,7 @@ openvzKBPerPages(void)
static long kb_per_pages;
if (kb_per_pages == 0) {
- kb_per_pages = sysconf(_SC_PAGESIZE);
- if (kb_per_pages > 0) {
- kb_per_pages /= 1024;
- } else {
+ if ((kb_per_pages = virGetSystemPageSizeKB()) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Can't determine page size"));
kb_per_pages = 0;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 100deed..30f202f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6694,7 +6694,7 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
char *nodemask = NULL;
char *mem_path = NULL;
int ret = -1;
- const long system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ const long system_page_size = virGetSystemPageSizeKB();
if (virDomainNumatuneHasPerNodeBinding(def->numatune) &&
!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
@@ -7986,7 +7986,7 @@ qemuBuildCommandLine(virConnectPtr conn,
def->mem.max_balloon = VIR_DIV_UP(def->mem.max_balloon, 1024) * 1024;
virCommandAddArgFormat(cmd, "%llu", def->mem.max_balloon / 1024);
if (def->mem.nhugepages && (!def->cpu || !def->cpu->ncells)) {
- const long system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ const long system_page_size = virGetSystemPageSizeKB();
char *mem_path = NULL;
if (def->mem.hugepages[0].size == system_page_size) {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1d3bee6..0a1c88e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1352,12 +1352,8 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
if (lastCpu)
*lastCpu = cpu;
- /* We got pages
- * We want kiloBytes
- * _SC_PAGESIZE is page size in Bytes
- * So calculate, but first lower the pagesize so we don't get overflow */
if (vm_rss)
- *vm_rss = rss * (sysconf(_SC_PAGESIZE) >> 10);
+ *vm_rss = rss * virGetSystemPageSizeKB();
VIR_DEBUG("Got status for %d/%d user=%llu sys=%llu cpu=%d rss=%ld",
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 5f56005..f2b9738 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1086,7 +1086,7 @@ safezero_mmap(int fd, off_t offset, off_t len)
/* align offset and length, rounding offset down and length up */
if (pagemask == 0)
- pagemask = ~(sysconf(_SC_PAGESIZE) - 1);
+ pagemask = ~(virGetSystemPageSize() - 1);
map_skip = offset - (offset & pagemask);
/* memset wants the mmap'ed file to be present on disk so create a
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 86564d4..e986c71 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -639,7 +639,7 @@ virNumaGetPageInfo(int node,
unsigned int *page_free)
{
int ret = -1;
- long system_page_size = sysconf(_SC_PAGESIZE);
+ long system_page_size = virGetSystemPageSize();
/* sysconf() returns page size in bytes,
* the @page_size is however in kibibytes */
@@ -717,7 +717,7 @@ virNumaGetPages(int node,
/* sysconf() returns page size in bytes,
* but we are storing the page size in kibibytes. */
- system_page_size = sysconf(_SC_PAGESIZE) / 1024;
+ system_page_size = virGetSystemPageSizeKB();
/* Query huge pages at first.
* On Linux systems, the huge pages pool cuts off the available memory and
@@ -841,7 +841,7 @@ virNumaSetPagePoolSize(int node,
char *end;
unsigned long long nr_count;
- if (page_size == sysconf(_SC_PAGESIZE) / 1024) {
+ if (page_size == virGetSystemPageSizeKB()) {
/* Special case as kernel handles system pages
* differently to huge pages. */
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 3037293..f3e8920 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2577,3 +2577,16 @@ virGetListenFDs(void)
}
#endif /* WIN32 */
+
+long virGetSystemPageSize(void)
+{
+ return sysconf(_SC_PAGESIZE);
+}
+
+long virGetSystemPageSizeKB(void)
+{
+ long val = sysconf(_SC_PAGESIZE);
+ if (val < 0)
+ return val;
+ return val / 1024;
+}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index f31bf88..d1173c1 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -244,4 +244,7 @@ VIR_ENUM_DECL(virTristateSwitch)
unsigned int virGetListenFDs(void);
+long virGetSystemPageSize(void);
+long virGetSystemPageSizeKB(void);
+
#endif /* __VIR_UTIL_H__ */
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 2473532..31a2a1b 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2736,7 +2736,7 @@ xenHypervisorGetMaxMemory(virConnectPtr conn,
int ret;
if (kb_per_pages == 0) {
- kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
+ kb_per_pages = virGetSystemPageSizeKB();
if (kb_per_pages <= 0)
kb_per_pages = 4;
}
@@ -2771,7 +2771,7 @@ xenHypervisorGetDomInfo(virConnectPtr conn, int id, virDomainInfoPtr info)
uint32_t domain_flags, domain_state, domain_shutdown_cause;
if (kb_per_pages == 0) {
- kb_per_pages = sysconf(_SC_PAGESIZE) / 1024;
+ kb_per_pages = virGetSystemPageSizeKB();
if (kb_per_pages <= 0)
kb_per_pages = 4;
}
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index eccf4b0..7adf781 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -22,7 +22,20 @@
#include "internal.h"
#include "virnuma.h"
+#include "virmock.h"
+#include "virutil.h"
#include <time.h>
+#include <unistd.h>
+
+long virGetSystemPageSize(void)
+{
+ return 4096;
+}
+
+long virGetSystemPageSizeKB(void)
+{
+ return 4;
+}
time_t time(time_t *t)
{
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 89afa81..77ee630 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -22,6 +22,7 @@
# include "cpu/cpu_map.h"
# include "virstring.h"
# include "storage/storage_driver.h"
+# include "virmock.h"
# include "testutilsqemu.h"
--
2.1.0
10 years, 3 months
[libvirt] [PATCH] storage: Need to clear pool prior to refreshPool during Autostart
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1176510
When storageDriverAutostart is called path virStateReload via a 'service
libvirtd reload', then because the volume list in the pool wasn't cleared
prior to the call, each volume would be listed multiple times (as many
times as we reload). I believe the issue would be introduced by commit
id '9e093f0b' at least for the libvirtd reload path, although I suppose
the introduction of virStateReload (commit id '70da0494') could be a
different cause.
Thus like other places prior to calling refreshPool, we need to call
virStoragePoolObjClearVols
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index e1dd448..ad92c9b 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -125,6 +125,7 @@ storageDriverAutostart(void)
}
if (started) {
+ virStoragePoolObjClearVols(pool);
if (backend->refreshPool(conn, pool) < 0) {
virErrorPtr err = virGetLastError();
if (backend->stopPool)
--
2.1.0
10 years, 3 months
[libvirt] [PATCH] util: recheck the validating backend when the firewalld start/stop
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1188088
When the firewalld is running and then start the libvirtd, libvirt
will set the current backend as VIR_FIREWALL_BACKEND_FIREWALLD.
But when firewalld is stop, we still try to use firewalld even it
is stopped, this will make the vm which has nwfilter cannot start
because systemd cannot find a running firewalld service.
We already have a Dbus callback functions before, add a recheck for
the validating backend in firewalld_dbus_filter_bridge and
nwfilterFirewalldDBusFilter callback functions to help us dynamic
change the validating backend.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/network/bridge_driver.c | 6 ++++++
src/nwfilter/nwfilter_driver.c | 6 ++++++
src/util/virfirewall.c | 8 ++++++++
src/util/virfirewall.h | 2 ++
5 files changed, 23 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f7f8ea2..dd953b2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1386,6 +1386,7 @@ virFirewallAddRuleFull;
virFirewallApply;
virFirewallFree;
virFirewallNew;
+virFirewallRecheckBackend;
virFirewallRemoveRule;
virFirewallRuleAddArg;
virFirewallRuleAddArgFormat;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c56e8f2..c0e77e6 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -60,6 +60,7 @@
#include "viruuid.h"
#include "viriptables.h"
#include "virlog.h"
+#include "virfirewall.h"
#include "virdnsmasq.h"
#include "configmake.h"
#include "virnetdev.h"
@@ -448,6 +449,11 @@ firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED,
DBusMessage *message, void *user_data ATTRIBUTE_UNUSED)
{
if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
+ "NameOwnerChanged")) {
+ virFirewallRecheckBackend();
+ }
+
+ if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
"NameOwnerChanged") ||
dbus_message_is_signal(message, "org.fedoraproject.FirewallD1",
"Reloaded"))
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 8e3db43..5f8c48d 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -29,6 +29,7 @@
#include "virdbus.h"
#include "virlog.h"
+#include "virfirewall.h"
#include "internal.h"
@@ -87,6 +88,11 @@ nwfilterFirewalldDBusFilter(DBusConnection *connection ATTRIBUTE_UNUSED,
void *user_data ATTRIBUTE_UNUSED)
{
if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
+ "NameOwnerChanged")) {
+ virFirewallRecheckBackend();
+ }
+
+ if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
"NameOwnerChanged") ||
dbus_message_is_signal(message, "org.fedoraproject.FirewallD1",
"Reloaded")) {
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index cd7afa5..ae00816 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -980,3 +980,11 @@ virFirewallApply(virFirewallPtr firewall)
virMutexUnlock(&ruleLock);
return ret;
}
+
+int
+virFirewallRecheckBackend(void)
+{
+ currentBackend = VIR_FIREWALL_BACKEND_AUTOMATIC;
+
+ return virFirewallValidateBackend(currentBackend);
+}
diff --git a/src/util/virfirewall.h b/src/util/virfirewall.h
index dbf3975..fa4bd8b 100644
--- a/src/util/virfirewall.h
+++ b/src/util/virfirewall.h
@@ -108,4 +108,6 @@ int virFirewallApply(virFirewallPtr firewall);
void virFirewallSetLockOverride(bool avoid);
+int virFirewallRecheckBackend(void);
+
#endif /* __VIR_FIREWALL_H__ */
--
1.8.3.1
10 years, 3 months