[libvirt] [libvirt-python PATCH 1/1] virDomainBlockCopy: initialize flags to 0
by Pavel Hrdina
An optional argument if not passed isn't modified by the
PyArg_ParseTuple function.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Sigh :/, pushed as trivial
libvirt-override.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index a461eda..a53b46f 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8171,7 +8171,7 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
char *destxml = NULL;
virTypedParameterPtr params = NULL;
int nparams = 0;
- unsigned int flags;
+ unsigned int flags = 0;
int c_retval;
if (!PyArg_ParseTuple(args, (char *) "Ozz|OI:virDomainBlockCopy",
--
2.0.4
10 years, 1 month
[libvirt] Libvirt clock/time settings doubt.
by Julio Faracco
Hi everyone!
What is the method/function responsible to setup time settings in libvirt?
Considering the example of libvirt documentation.
<clock offset='localtime'>
<timer name='rtc' tickpolicy='catchup' track='guest'>
<catchup threshold='123' slew='120' limit='10000'/>
</timer>
<timer name='pit' tickpolicy='delay'/>
</clock>
...
I know where this XML will be parsed. But I don't know where libvirt will
pass clock/time settings to QEMU.
Can somebody explain to me or send me a documentation about it?
I passed two weeks trying to discover the sequence of function calls.
Thanks guys!
*--*
*Julio Cesar Faracco*
10 years, 1 month
[libvirt] [PATCH] Add support for /run/initctl
by Rick Harris
Newer versions of Debian use `/run/initctl` instead of `/dev/initctl`. This
patch updates the code to search for the FIFO from a list of well-known
locations.
In the FreeBSD case, as before, we fall-back to the `/etc/.initctl` stub.
---
src/util/virinitctl.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c
index a6fda3b..c4b48d4 100644
--- a/src/util/virinitctl.c
+++ b/src/util/virinitctl.c
@@ -46,12 +46,6 @@
* Copyright (C) 1995-2004 Miquel van Smoorenburg
*/
-# if defined(__FreeBSD_kernel__)
-# define VIR_INITCTL_FIFO "/etc/.initctl"
-# else
-# define VIR_INITCTL_FIFO "/dev/initctl"
-# endif
-
# define VIR_INITCTL_MAGIC 0x03091969
# define VIR_INITCTL_CMD_START 0
# define VIR_INITCTL_CMD_RUNLVL 1
@@ -124,6 +118,13 @@ virInitctlSetRunLevel(virInitctlRunLevel level)
struct virInitctlRequest req;
int fd = -1;
int ret = -1;
+ const char *initctl_fifo = NULL;
+ size_t i = 0;
+ const char *initctl_fifos[] = {
+ "/run/initctl",
+ "/dev/initctl",
+ "/etc/.initctl",
+ };
memset(&req, 0, sizeof(req));
@@ -133,22 +134,31 @@ virInitctlSetRunLevel(virInitctlRunLevel level)
/* Yes it is an 'int' field, but wants a numeric character. Go figure */
req.runlevel = '0' + level;
- if ((fd = open(VIR_INITCTL_FIFO,
- O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY)) < 0) {
- if (errno == ENOENT) {
- ret = 0;
+ for (i = 0; i < ARRAY_CARDINALITY(initctl_fifos); i++) {
+ initctl_fifo = initctl_fifos[i];
+
+ if ((fd = open(initctl_fifo,
+ O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY)) >= 0)
+ break;
+
+ if (errno != ENOENT) {
+ virReportSystemError(errno,
+ _("Cannot open init control %s"),
+ initctl_fifo);
goto cleanup;
}
- virReportSystemError(errno,
- _("Cannot open init control %s"),
- VIR_INITCTL_FIFO);
+ }
+
+ /* Ensure we found a valid initctl fifo */
+ if (fd < 0) {
+ ret = 0;
goto cleanup;
}
if (safewrite(fd, &req, sizeof(req)) != sizeof(req)) {
virReportSystemError(errno,
_("Failed to send request to init control %s"),
- VIR_INITCTL_FIFO);
+ initctl_fifo);
goto cleanup;
}
--
1.9.1
10 years, 1 month
[libvirt] libvirt build failure on armhf (Re: [Xen-devel] [libvirt bisection] complete build-armhf-libvirt)
by Ian Campbell
Hi,
On Fri, 2014-10-17 at 00:42 +0100, xen.org wrote:
> *** Found and reproduced problem changeset ***
>
> Bug is in tree: libvirt git://libvirt.org/libvirt.git
> Bug introduced: 24c160376275b7d31f71fbde83af8183cbf744a7
> Bug not present: 69f7b67d55316ab7b28fb904b346943497b856a1
The Xen automated build tests have discovered a built error on armhf. I
don't think it is Xen specific. Our bisector has fingered the changeset
below. I've had a skim of the git log from there to master and of the
outstanding patches on libvir list and I don't see anything which is
obviously a related fix, so I hope this is still useful/relevant.
An instance of the failure can be seen at
http://www.chiark.greenend.org.uk/~xensrcts/logs/30765/build-armhf-libvir...
The logs say:
util/virsocketaddr.c: In function 'virSocketAddrIsNumericLocalhost':
util/virsocketaddr.c:904:17: error: cast increases required alignment of target type [-Werror=cast-align]
util/virsocketaddr.c:909:17: error: cast increases required alignment of target type [-Werror=cast-align]
Ian.
> commit 24c160376275b7d31f71fbde83af8183cbf744a7
> Author: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
> Date: Tue Oct 7 12:07:31 2014 +0800
>
> conf: add check if migration_host is a localhost address
>
> Signed-off-by: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
>
> Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
>
>
> For bisection revision-tuple graph see:
> http://www.chiark.greenend.org.uk/~xensrcts/results/bisect.libvirt.build-...
> Revision IDs in each graph node refer, respectively, to the Trees above.
>
> ----------------------------------------
> Searching for failure / basis pass:
> 30765 fail [host=marilith-n4] / 30748 ok.
> Failure / basis pass flights: 30765 / 30748
> Tree: gnulib_libvirt git://drall.uk.xensource.com:9419/git://git.sv.gnu.org/gnulib.git%20[fetc...
> Tree: libvirt git://libvirt.org/libvirt.git
> Tree: qemuu git://xenbits.xen.org/staging/qemu-upstream-unstable.git
> Tree: xen git://xenbits.xen.org/xen.git
> Latest b155b0649814b20e635a2db305696710fa1037ce e9a1c4384c4f83a8e0d5d98c80369ecfd5b3f2e0 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> Basis pass b155b0649814b20e635a2db305696710fa1037ce 4d1852c48541a29e3c47caf0f2b801dfcb6579db c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 7d96cc5c4b2670a4220a50746fa17a0e8a4da1c2
> Generating revisions with ./adhoc-revtuple-generator git://drall.uk.xensource.com:9419/git://git.sv.gnu.org/gnulib.git%20[fetc... git://libvirt.org/libvirt.git#4d1852c48541a29e3c47caf0f2b801dfcb6579db-e9... git://xenbits.xen.org/staging/qemu-upstream-unstable.git#c9d8f8b755e8960e... git://xenbits.xen.org/xen.git#7d96cc5c4b2670a4220a50746fa17a0e8a4da1c2-4d...
> + exec
> + sh -xe
> + cd /export/home/osstest/repos/libvirt
> + git remote set-url origin git://drall.uk.xensource.com:9419/git://libvirt.org/libvirt.git
> + git fetch -p origin +refs/heads/*:refs/remotes/origin/*
> + exec
> + sh -xe
> + cd /export/home/osstest/repos/xen
> + git remote set-url origin git://drall.uk.xensource.com:9419/git://xenbits.xen.org/xen.git
> + git fetch -p origin +refs/heads/*:refs/remotes/origin/*
> + exec
> + sh -xe
> + cd /export/home/osstest/repos/libvirt
> + git remote set-url origin git://drall.uk.xensource.com:9419/git://libvirt.org/libvirt.git
> + git fetch -p origin +refs/heads/*:refs/remotes/origin/*
> + exec
> + sh -xe
> + cd /export/home/osstest/repos/xen
> + git remote set-url origin git://drall.uk.xensource.com:9419/git://xenbits.xen.org/xen.git
> + git fetch -p origin +refs/heads/*:refs/remotes/origin/*
> Loaded 3959 nodes in revision graph
> Searching for test results:
> 30748 pass b155b0649814b20e635a2db305696710fa1037ce 4d1852c48541a29e3c47caf0f2b801dfcb6579db c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 7d96cc5c4b2670a4220a50746fa17a0e8a4da1c2
> 30765 fail b155b0649814b20e635a2db305696710fa1037ce e9a1c4384c4f83a8e0d5d98c80369ecfd5b3f2e0 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30776 pass b155b0649814b20e635a2db305696710fa1037ce 4d1852c48541a29e3c47caf0f2b801dfcb6579db c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 7d96cc5c4b2670a4220a50746fa17a0e8a4da1c2
> 30777 fail b155b0649814b20e635a2db305696710fa1037ce e9a1c4384c4f83a8e0d5d98c80369ecfd5b3f2e0 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30779 fail b155b0649814b20e635a2db305696710fa1037ce 3d6c07f7f804be936df800eed749d01873da5a45 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30780 fail b155b0649814b20e635a2db305696710fa1037ce 24c160376275b7d31f71fbde83af8183cbf744a7 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30781 pass b155b0649814b20e635a2db305696710fa1037ce 4d1852c48541a29e3c47caf0f2b801dfcb6579db c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30783 pass b155b0649814b20e635a2db305696710fa1037ce 6c31911a964f42f83d7f6b7c86ad40c17c71fcea c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30784 pass b155b0649814b20e635a2db305696710fa1037ce 69f7b67d55316ab7b28fb904b346943497b856a1 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30785 fail b155b0649814b20e635a2db305696710fa1037ce 24c160376275b7d31f71fbde83af8183cbf744a7 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30786 pass b155b0649814b20e635a2db305696710fa1037ce 69f7b67d55316ab7b28fb904b346943497b856a1 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30787 fail b155b0649814b20e635a2db305696710fa1037ce 24c160376275b7d31f71fbde83af8183cbf744a7 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30789 pass b155b0649814b20e635a2db305696710fa1037ce 69f7b67d55316ab7b28fb904b346943497b856a1 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> 30790 fail b155b0649814b20e635a2db305696710fa1037ce 24c160376275b7d31f71fbde83af8183cbf744a7 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> Searching for interesting versions
> Result found: flight 30748 (pass), for basis pass
> Result found: flight 30765 (fail), for basis failure
> Repro found: flight 30776 (pass), for basis pass
> Repro found: flight 30777 (fail), for basis failure
> 0 revisions at b155b0649814b20e635a2db305696710fa1037ce 69f7b67d55316ab7b28fb904b346943497b856a1 c9d8f8b755e8960edf7725e05f3e6ac743a5e12e 4d57153b52a36183d58e8de6ba613929f906386a
> No revisions left to test, checking graph state.
> Result found: flight 30784 (pass), for last pass
> Result found: flight 30785 (fail), for first failure
> Repro found: flight 30786 (pass), for last pass
> Repro found: flight 30787 (fail), for first failure
> Repro found: flight 30789 (pass), for last pass
> Repro found: flight 30790 (fail), for first failure
>
> *** Found and reproduced problem changeset ***
>
> Bug is in tree: libvirt git://libvirt.org/libvirt.git
> Bug introduced: 24c160376275b7d31f71fbde83af8183cbf744a7
> Bug not present: 69f7b67d55316ab7b28fb904b346943497b856a1
>
> + exec
> + sh -xe
> + cd /export/home/osstest/repos/libvirt
> + git remote set-url origin git://drall.uk.xensource.com:9419/git://libvirt.org/libvirt.git
> + git fetch -p origin +refs/heads/*:refs/remotes/origin/*
>
> commit 24c160376275b7d31f71fbde83af8183cbf744a7
> Author: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
> Date: Tue Oct 7 12:07:31 2014 +0800
>
> conf: add check if migration_host is a localhost address
>
> Signed-off-by: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
>
> Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
>
> Revision graph left in /home/xc_osstest/results/bisect.libvirt.build-armhf-libvirt.libvirt-build.{dot,ps,png,html}.
> ----------------------------------------
> 30790: tolerable ALL FAIL
>
> flight 30790 libvirt real-bisect [real]
> http://www.chiark.greenend.org.uk/~xensrcts/logs/30790/
>
> Failures :-/ but no regressions.
>
> Tests which did not succeed,
> including tests which could not be run:
> build-armhf-libvirt 5 libvirt-build fail baseline untested
>
>
> jobs:
> build-armhf-libvirt fail
>
>
> ------------------------------------------------------------
> sg-report-flight on osstest.cam.xci-test.com
> logs: /home/xc_osstest/logs
> images: /home/xc_osstest/images
>
> Logs, config files, etc. are available at
> http://www.chiark.greenend.org.uk/~xensrcts/logs
>
> Test harness code can be found at
> http://xenbits.xensource.com/gitweb?p=osstest.git;a=summary
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel(a)lists.xen.org
> http://lists.xen.org/xen-devel
10 years, 1 month
[libvirt] [PATCH 0/5] parallels: continue rewriting code to use sdk
by Dmitry Guryanov
This patch series replaces a series of functions, which
retieve different domains info and modifies domains state
with new ones, which use parallels sdk instead of executing
prlctl command.
These functions don't use cached domains list
_parallelsConn.domains, so when we rewrite all code, we
will be able to remove it.
Alexander Burluka (1):
parallels: obtain domain info with SDK
Dmitry Guryanov (4):
parallels: list domains with parallels SDK
parallels: implement lookup functions with SDK
parallels: move IS_CT macro to parallels_utils.h
parallels: change domains state with SDK
src/parallels/parallels_driver.c | 178 +-----
src/parallels/parallels_sdk.c | 1189 ++++++++++++++++++++++++++++++++++++++
src/parallels/parallels_sdk.h | 14 +
src/parallels/parallels_utils.h | 3 +
4 files changed, 1230 insertions(+), 154 deletions(-)
--
1.9.3
10 years, 1 month
[libvirt] [python PATCH] Fix flags cannot get right value for blockCopy function
by Luyao Huang
When use blockCopy, flags cannot get a right value, because
PyArg_ParseTuple want to get 6 parameters and blockCopy only
pass 5.Flags will get a unpredictable value, this will make
this function cannot be used.And error just like:
unsupported flags (0x7f6c) in function qemuDomainBlockCopy
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
libvirt-override.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index c887b71..4999ac3 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8175,8 +8175,7 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
int c_retval;
if (!PyArg_ParseTuple(args, (char *) "Ozz|Oi:virDomainBlockCopy",
- &pyobj_dom, &disk, &destxml, &pyobj_dict, ¶ms,
- &flags))
+ &pyobj_dom, &disk, &destxml, &pyobj_dict, &flags))
return VIR_PY_INT_FAIL;
if (PyDict_Check(pyobj_dict)) {
--
1.8.3.1
10 years, 1 month
[libvirt] [PATCH v2] Fix cast errors with clang
by Roman Bogorodskiy
Build with clang fails with:
CC util/libvirt_util_la-virsocketaddr.lo
util/virsocketaddr.c:904:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
inet4 = (struct sockaddr_in*) res->ai_addr;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virsocketaddr.c:909:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in6 *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
inet6 = (struct sockaddr_in6*) res->ai_addr;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
Fix that by replacing virSocketAddrParseInternal() call with
virSocketAddrParse() in the virSocketAddrIsNumericLocalhost() function.
virSocketAddrParse stores an address in virSocketAddr.
virSocketAddr uses a union to store an address, so it doesn't
need casting.
---
src/util/virsocketaddr.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 5f54e68..da0a9f1 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -890,28 +890,20 @@ virSocketAddrNumericFamily(const char *address)
bool
virSocketAddrIsNumericLocalhost(const char *addr)
{
- struct addrinfo *res;
+ virSocketAddr res;
struct in_addr tmp = { .s_addr = htonl(INADDR_LOOPBACK) };
- struct sockaddr_in *inet4;
- struct sockaddr_in6 *inet6;
bool ret = false;
- if (virSocketAddrParseInternal(&res, addr, AF_UNSPEC, false) < 0)
+ if (virSocketAddrParse(&res, addr, AF_UNSPEC) < 0)
return ret;
- switch (res->ai_addr->sa_family) {
+ switch (res.data.stor.ss_family) {
case AF_INET:
- inet4 = (struct sockaddr_in*) res->ai_addr;
- ret = memcmp(&inet4->sin_addr.s_addr, &tmp.s_addr,
- sizeof(inet4->sin_addr.s_addr)) == 0;
- break;
+ return memcmp(&res.data.inet4.sin_addr.s_addr, &tmp.s_addr,
+ sizeof(res.data.inet4.sin_addr.s_addr)) == 0;
case AF_INET6:
- inet6 = (struct sockaddr_in6*) res->ai_addr;
- ret = IN6_IS_ADDR_LOOPBACK(&(inet6->sin6_addr));
- break;
+ return IN6_IS_ADDR_LOOPBACK(&res.data.inet6.sin6_addr);
}
- freeaddrinfo(res);
return ret;
-
}
--
2.0.2
10 years, 1 month
[libvirt] [python PATCH 0/3] Fix multiple python binding issues
by Peter Krempa
Luyao Huang (1):
Fix parsing of 'flags' argument for bulk stats functions
Peter Krempa (2):
Fix function name when parsing arguments in libvirt_virNodeAllocPages
Fix rest of unsigned integer handling
generator.py | 2 +-
libvirt-lxc-override.c | 2 +-
libvirt-override.c | 132 ++++++++++++++++++++++++------------------------
libvirt-qemu-override.c | 4 +-
4 files changed, 70 insertions(+), 70 deletions(-)
--
2.1.0
10 years, 1 month
[libvirt] [PATCH v4] network: Add bandwidth support to ethernet interfaces
by Anirban Chakraborty
v4:
Changed function virNetDevSupportBandwidth to use switch statement.
Fixed syntax issues
Fold the two patches into one as the second patch was a one liner
v3:
Addressed issues pointed out in V2
Split into two patches
v2:
Addressed comments raised in review of V1.
Consolidate calls to virNetDevBandwidthSet.
Clear bandwidth settings when the interface is detached or domain
destroyed.
v1:
Ethernet interfaces in libvirt currently do not support bandwidth setting.
For example, following xml file for an interface will not apply these
settings to corresponding qdiscs.
<interface type="ethernet">
<mac address="02:36:1d:18:2a:e4"/>
<model type="virtio"/>
<script path=""/>
<target dev="tap361d182a-e4"/>
<bandwidth>
<inbound average="984" peak="1024" burst="64"/>
<outbound average="2000" peak="2048" burst="128"/>
</bandwidth>
</interface>
Signed-off-by: Anirban Chakraborty <abchak(a)juniper.net>
---
src/conf/domain_conf.h | 21 +++++++++++++++++++++
src/lxc/lxc_driver.c | 3 +++
src/lxc/lxc_process.c | 18 +++++++++---------
src/qemu/qemu_command.c | 25 +++++++++++++++++++------
src/qemu/qemu_command.h | 2 ++
src/qemu/qemu_driver.c | 3 +++
src/qemu/qemu_hotplug.c | 12 ++++++++++++
src/qemu/qemu_process.c | 3 +++
src/util/virnetdevmacvlan.c | 10 ----------
src/util/virnetdevmacvlan.h | 1 -
10 files changed, 72 insertions(+), 26 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index afa3da6..59fdfb2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2848,4 +2848,25 @@ int virDomainObjSetMetadata(virDomainObjPtr vm,
bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def)
ATTRIBUTE_NONNULL(1);
+static inline bool virNetDevSupportBandwidth(virDomainNetType type)
+{
+ switch (type) {
+ case VIR_DOMAIN_NET_TYPE_BRIDGE:
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ case VIR_DOMAIN_NET_TYPE_DIRECT:
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ return true;
+ case VIR_DOMAIN_NET_TYPE_USER:
+ case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
+ case VIR_DOMAIN_NET_TYPE_SERVER:
+ case VIR_DOMAIN_NET_TYPE_CLIENT:
+ case VIR_DOMAIN_NET_TYPE_MCAST:
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
+ case VIR_DOMAIN_NET_TYPE_HOSTDEV:
+ case VIR_DOMAIN_NET_TYPE_LAST:
+ break;
+ }
+ return false;
+}
+
#endif /* __DOMAIN_CONF_H */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index b3e506f..a6f1f8a 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -72,6 +72,7 @@
#include "viraccessapicheck.h"
#include "viraccessapichecklxc.h"
#include "virhostdev.h"
+#include "qemu/qemu_command.h"
#define VIR_FROM_THIS VIR_FROM_LXC
@@ -4634,6 +4635,8 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
detach = vm->def->nets[detachidx];
+ qemuDomainClearNetBandwidth(vm);
+
switch (virDomainNetGetActualType(detach)) {
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_NETWORK:
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index ed30c37..3192011 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -274,11 +274,6 @@ char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
if (virNetDevSetOnline(parentVeth, true) < 0)
goto cleanup;
- if (virNetDevBandwidthSet(net->ifname,
- virDomainNetGetActualBandwidth(net),
- false) < 0)
- goto cleanup;
-
if (net->filter &&
virDomainConfNWFilterInstantiate(conn, vm->uuid, net) < 0)
goto cleanup;
@@ -300,6 +295,7 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
virNetDevBandwidthPtr bw;
virNetDevVPortProfilePtr prof;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
+ const char *linkdev = virDomainNetGetActualDirectDev(net);
/* XXX how todo bandwidth controls ?
* Since the 'net-ifname' is about to be moved to a different
@@ -329,14 +325,13 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
if (virNetDevMacVLanCreateWithVPortProfile(
net->ifname, &net->mac,
- virDomainNetGetActualDirectDev(net),
+ linkdev,
virDomainNetGetActualDirectMode(net),
false, def->uuid,
- virDomainNetGetActualVirtPortProfile(net),
+ prof,
&res_ifname,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
- cfg->stateDir,
- virDomainNetGetActualBandwidth(net), 0) < 0)
+ cfg->stateDir, 0) < 0)
goto cleanup;
ret = res_ifname;
@@ -450,6 +445,11 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
goto cleanup;
}
+ /* set network bandwidth */
+ if (virNetDevBandwidthSet(def->nets[i]->ifname,
+ virDomainNetGetActualBandwidth(def->nets[i]), false) < 0)
+ goto cleanup;
+
(*veths)[(*nveths)-1] = veth;
/* Make sure all net definitions will have a name in the container */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8cb0865..3645ace 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -191,7 +191,6 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
virDomainNetGetActualVirtPortProfile(net),
&res_ifname,
vmop, cfg->stateDir,
- virDomainNetGetActualBandwidth(net),
macvlan_create_flags);
if (rc >= 0) {
virDomainAuditNetDevice(def, net, res_ifname, true);
@@ -371,11 +370,6 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
&net->mac) < 0)
goto cleanup;
- if (virNetDevBandwidthSet(net->ifname,
- virDomainNetGetActualBandwidth(net),
- false) < 0)
- goto cleanup;
-
if (net->filter &&
virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) {
goto cleanup;
@@ -7427,6 +7421,13 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
goto cleanup;
}
+ /* Set Bandwidth */
+ if (virNetDevSupportBandwidth(actualType) &&
+ virNetDevBandwidthSet(net->ifname,
+ virDomainNetGetActualBandwidth(net),
+ false) < 0)
+ goto cleanup;
+
if ((actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_ETHERNET ||
@@ -12452,3 +12453,15 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
virStringFreeList(progenv);
return def;
}
+
+void qemuDomainClearNetBandwidth(virDomainObjPtr vm)
+{
+ size_t i;
+ virDomainNetType type;
+
+ for (i = 0; i < vm->def->nnets; i++) {
+ type = virDomainNetGetActualType(vm->def->nets[i]);
+ if (virNetDevSupportBandwidth(type))
+ virNetDevBandwidthClear(vm->def->nets[i]->ifname);
+ }
+}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index aa40c9e..7963a91 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -277,4 +277,6 @@ int qemuCheckDiskConfig(virDomainDiskDefPtr disk);
bool
qemuCheckFips(void);
+
+void qemuDomainClearNetBandwidth(virDomainObjPtr vm);
#endif /* __QEMU_COMMAND_H__*/
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7c9b1ab..8ad644a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2196,6 +2196,9 @@ qemuDomainDestroyFlags(virDomainPtr dom,
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ /* Clear network bandwidth */
+ qemuDomainClearNetBandwidth(vm);
+
qemuDomainSetFakeReboot(driver, vm, false);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1e504ec..f627e69 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -50,6 +50,7 @@
#include "virstring.h"
#include "virtime.h"
#include "storage/storage_driver.h"
+#include "domain_conf.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -948,6 +949,12 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
goto cleanup;
}
+ /* Set Bandwidth */
+ if (virNetDevSupportBandwidth(actualType) &&
+ virNetDevBandwidthSet(net->ifname,
+ virDomainNetGetActualBandwidth(net), false) < 0)
+ goto cleanup;
+
for (i = 0; i < tapfdSize; i++) {
if (virSecurityManagerSetTapFDLabel(driver->securityManager,
vm->def, tapfd[i]) < 0)
@@ -3516,6 +3523,11 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
}
}
+ if (virNetDevSupportBandwidth(virDomainNetGetActualType(detach)) &&
+ virNetDevBandwidthClear(detach->ifname) < 0)
+ VIR_WARN("cannot clear bandwidth setting for device : %s",
+ detach->ifname);
+
qemuDomainMarkDeviceForRemoval(vm, &detach->info);
qemuDomainObjEnterMonitor(driver, vm);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 95548aa..4d95ec4 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4825,6 +4825,9 @@ void qemuProcessStop(virQEMUDriverPtr driver,
virStrerror(errno, ebuf, sizeof(ebuf)));
}
+ /* Clear network bandwidth */
+ qemuDomainClearNetBandwidth(vm);
+
virDomainConfVMNWFilterTeardown(vm);
if (cfg->macFilter) {
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index c83341c..956a96b 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -811,7 +811,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
char **res_ifname,
virNetDevVPortProfileOp vmOp,
char *stateDir,
- virNetDevBandwidthPtr bandwidth,
unsigned int flags)
{
const char *type = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
@@ -925,14 +924,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
rc = 0;
}
- if (virNetDevBandwidthSet(cr_ifname, bandwidth, false) < 0) {
- if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP)
- VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
- else
- rc = -1;
- goto disassociate_exit;
- }
-
if (vmOp == VIR_NETDEV_VPORT_PROFILE_OP_CREATE ||
vmOp == VIR_NETDEV_VPORT_PROFILE_OP_RESTORE) {
/* Only directly register upon a create or restore (restarting
@@ -1076,7 +1067,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname ATTRIBUTE_UNUSED,
char **res_ifname ATTRIBUTE_UNUSED,
virNetDevVPortProfileOp vmop ATTRIBUTE_UNUSED,
char *stateDir ATTRIBUTE_UNUSED,
- virNetDevBandwidthPtr bandwidth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(0, -1);
diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
index 41aa4e2..f08d32b 100644
--- a/src/util/virnetdevmacvlan.h
+++ b/src/util/virnetdevmacvlan.h
@@ -68,7 +68,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
char **res_ifname,
virNetDevVPortProfileOp vmop,
char *stateDir,
- virNetDevBandwidthPtr bandwidth,
unsigned int flags)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
--
1.9.1
10 years, 1 month
[libvirt] [PATCH] Fix cast errors with clang
by Roman Bogorodskiy
Build with clang fails with:
CC util/libvirt_util_la-virsocketaddr.lo
util/virsocketaddr.c:904:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
inet4 = (struct sockaddr_in*) res->ai_addr;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virsocketaddr.c:909:17: error: cast from 'struct sockaddr *' to
'struct sockaddr_in6 *' increases required alignment from 1 to 4
[-Werror,-Wcast-align]
inet6 = (struct sockaddr_in6*) res->ai_addr;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
Fix by introducing a union of the appropriate sturcts.
---
src/util/virsocketaddr.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 5f54e68..162108c 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -892,22 +892,25 @@ virSocketAddrIsNumericLocalhost(const char *addr)
{
struct addrinfo *res;
struct in_addr tmp = { .s_addr = htonl(INADDR_LOOPBACK) };
- struct sockaddr_in *inet4;
- struct sockaddr_in6 *inet6;
+ union {
+ struct sockaddr *addr;
+ struct sockaddr_in *inet4;
+ struct sockaddr_in6 *inet6;
+ } sa;
bool ret = false;
if (virSocketAddrParseInternal(&res, addr, AF_UNSPEC, false) < 0)
return ret;
+ sa.addr = res->ai_addr;
+
switch (res->ai_addr->sa_family) {
case AF_INET:
- inet4 = (struct sockaddr_in*) res->ai_addr;
- ret = memcmp(&inet4->sin_addr.s_addr, &tmp.s_addr,
- sizeof(inet4->sin_addr.s_addr)) == 0;
+ ret = memcmp(&sa.inet4->sin_addr.s_addr, &tmp.s_addr,
+ sizeof(sa.inet4->sin_addr.s_addr)) == 0;
break;
case AF_INET6:
- inet6 = (struct sockaddr_in6*) res->ai_addr;
- ret = IN6_IS_ADDR_LOOPBACK(&(inet6->sin6_addr));
+ ret = IN6_IS_ADDR_LOOPBACK(&(sa.inet6->sin6_addr));
break;
}
--
2.0.2
10 years, 1 month