]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
9 years agodomain-conf: escape string for socket attribute
Pavel Hrdina [Mon, 31 Aug 2015 13:33:49 +0000 (15:33 +0200)]
domain-conf: escape string for socket attribute

Commit d091518b tried to escape all strings in produced XML, but missed
this one.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoutil: don't use netlink to save/set mac for macvtap+passthrough+802.1Qbh
Laine Stump [Wed, 26 Aug 2015 04:18:26 +0000 (00:18 -0400)]
util: don't use netlink to save/set mac for macvtap+passthrough+802.1Qbh

Before libvirt sets the MAC address of the physdev (the physical
ethernet device) linked to a macvtap passthrough device, it always
saves the previous MAC address to restore when the guest is finished
(following a "leave nothing behind" policy). For a long time it
accomplished the save/restore with a combination of
ioctl(SIOCGIFHWADDR) and ioctl(SIOCSIFHWADDR), but in commit cbfe38c
(first in libvirt 1.2.15) this was changed to use netlink RTM_GETLINK
and RTM_SETLINK commands sent to the Physical Function (PF) of any
device that was detected to be a Virtual Function (VF).

We later found out that this caused problems with any devices using
the Cisco enic driver (e.g. vmfex cards) because the enic driver
hasn't implemented the function that is called to gather the
information in the IFLA_VFINFO_LIST attribute of RTM_GETLINK
(ndo_get_vf_config() for those keeping score), so we would never get
back a useful response.

In an ideal world, all drivers would implement all functions, but it
turns out that in this case we can work around this omission without
any bad side effects - since all macvtap passthrough <interface>
definitions pointing to a physdev that uses the enic driver *must*
have a <virtualport type='802.1Qbh'>, and since no other type of
ethernet devices use 802.1Qbh, libvirt can change its behavior in this
case to use the old-style.  ioctl(SIOC[GS]IFHWADDR).  That's what this
patch does.

Resolves:  https://bugzilla.redhat.com/show_bug.cgi?id=1257004

9 years agoutil: make virNetDev(Replace|Restore)MacAddress public functions
Laine Stump [Mon, 31 Aug 2015 21:09:01 +0000 (17:09 -0400)]
util: make virNetDev(Replace|Restore)MacAddress public functions

These functions were made static as a part of commit cbfe38c since
they were no longer called from outside virnetdev.c. We once again
need to call them from another file, so this patch makes them once
again public.

9 years agoremoteClientCloseFunc: Don't mangle connection object refcount
Michal Privoznik [Thu, 3 Sep 2015 10:11:53 +0000 (12:11 +0200)]
remoteClientCloseFunc: Don't mangle connection object refcount

Well, in 8ad126e6 we tried to fix a memory corruption problem.
However, the fix was not as good as it could be. I mean, the
commit has one line more than it should. I've noticed this output
just recently:

  # ./run valgrind --leak-check=full --show-reachable=yes ./tools/virsh domblklist gentoo
  ==17019== Memcheck, a memory error detector
  ==17019== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
  ==17019== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
  ==17019== Command: /home/zippy/work/libvirt/libvirt.git/tools/.libs/virsh domblklist gentoo
  ==17019==
  Target     Source
  ------------------------------------------------
  fda        /var/lib/libvirt/images/fd.img
  vda        /var/lib/libvirt/images/gentoo.qcow2
  hdc        /home/zippy/tmp/install-amd64-minimal-20150402.iso

  ==17019== Thread 2:
  ==17019== Invalid read of size 4
  ==17019==    at 0x4EFF5B4: virObjectUnref (virobject.c:258)
  ==17019==    by 0x5038CFF: remoteClientCloseFunc (remote_driver.c:552)
  ==17019==    by 0x5069D57: virNetClientCloseLocked (virnetclient.c:685)
  ==17019==    by 0x506C848: virNetClientIncomingEvent (virnetclient.c:1852)
  ==17019==    by 0x5082136: virNetSocketEventHandle (virnetsocket.c:1913)
  ==17019==    by 0x4ECD64E: virEventPollDispatchHandles (vireventpoll.c:509)
  ==17019==    by 0x4ECDE02: virEventPollRunOnce (vireventpoll.c:658)
  ==17019==    by 0x4ECBF00: virEventRunDefaultImpl (virevent.c:308)
  ==17019==    by 0x130386: vshEventLoop (vsh.c:1864)
  ==17019==    by 0x4F1EB07: virThreadHelper (virthread.c:206)
  ==17019==    by 0xA8462D3: start_thread (in /lib64/libpthread-2.20.so)
  ==17019==    by 0xAB441FC: clone (in /lib64/libc-2.20.so)
  ==17019==  Address 0x139023f4 is 4 bytes inside a block of size 240 free'd
  ==17019==    at 0x4C2B1F0: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==17019==    by 0x4EA8949: virFree (viralloc.c:582)
  ==17019==    by 0x4EFF6D0: virObjectUnref (virobject.c:273)
  ==17019==    by 0x4FE74D6: virConnectClose (libvirt.c:1390)
  ==17019==    by 0x13342A: virshDeinit (virsh.c:406)
  ==17019==    by 0x134A37: main (virsh.c:950)

The problem is, when registering remoteClientCloseFunc(), it's
conn->closeCallback which is ref'd. But in the function itself
it's conn->closeCallback->conn what is unref'd. This is causing
imbalance in reference counting. Moreover, there's no need for
the remote driver to increase/decrease conn refcount since it's
not used anywhere. It's just merely passed to client registered
callback. And for that purpose it's correctly ref'd in
virConnectRegisterCloseCallback() and then unref'd in
virConnectUnregisterCloseCallback().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovshInit: Don't leak @histsize_env
Michal Privoznik [Thu, 3 Sep 2015 12:37:14 +0000 (14:37 +0200)]
vshInit: Don't leak @histsize_env

Caller is responsible for freeing the result of virStringJoin()
when no longer needed:

==10701== 1 bytes in 1 blocks are definitely lost in loss record 1 of 806
==10701==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10701==    by 0xAADB679: strdup (in /lib64/libc-2.20.so)
==10701==    by 0x4F18655: virStrdup (virstring.c:726)
==10701==    by 0x4F175AF: virStringJoin (virstring.c:165)
==10701==    by 0x131D4D: vshReadlineInit (vsh.c:2572)
==10701==    by 0x1322DF: vshInit (vsh.c:2736)
==10701==    by 0x1347C1: main (virsh.c:907)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorage: Handle failure from refreshVol
John Ferlan [Mon, 24 Aug 2015 16:38:13 +0000 (12:38 -0400)]
storage: Handle failure from refreshVol

Commit id '155ca616' added the 'refreshVol' API. In an NFS root-squash
environment it was possible that if the just created volume from XML wasn't
properly created with the right uid/gid and/or mode, then the followup
refreshVol will fail to open the volume in order to get the allocation/
capacity values. This would leave the volume still on the server and
cause a libvirtd crash because 'voldef' would be in the pool list, but
the cleanup code would free it.

9 years agostorage: Correct the 'mode' check
John Ferlan [Mon, 24 Aug 2015 16:48:40 +0000 (12:48 -0400)]
storage: Correct the 'mode' check

Commit id '7c2d65dde2' changed the default value of mode to be -1 if not
supplied in the XML, which should cause creation of the volume using the
default mode of VIR_STORAGE_DEFAULT_VOL_PERM_MODE; however, the check
made was whether mode was '0' or not to use default or provided value.

This patch fixes the issue to check if the 'mode' was provided in the XML
and use that value.

9 years agovirfile: Introduce virFileUnlink
John Ferlan [Mon, 24 Aug 2015 21:00:02 +0000 (17:00 -0400)]
virfile: Introduce virFileUnlink

In an NFS root-squashed environment the 'vol-delete' command will fail to
'unlink' the target volume since it was created under a different uid:gid.

This code continues the concepts introduced in virFileOpenForked and
virDirCreate[NoFork] with respect to running the unlink command under
the uid/gid of the child. Unlike the other two, don't retry on EACCES
(that's why we're here doing this now).

9 years agovirfile: Add error for root squash change mode failure
John Ferlan [Mon, 24 Aug 2015 16:37:41 +0000 (12:37 -0400)]
virfile: Add error for root squash change mode failure

This will only be seen when debugging, but in order to help determine
whether a virFileOpenForceOwnerMode failed during an NFS root-squash
volume/file creation, add an error message from the child.

9 years agoqemu: add udp interface support
Jonathan Toppins [Sat, 29 Aug 2015 20:19:10 +0000 (16:19 -0400)]
qemu: add udp interface support

Adds a new interface type using UDP sockets, this seems only applicable
to QEMU but have edited tree-wide to support the new interface type.

The interface type required the addition of a "localaddr" (local
address), this then maps into the following xml and qemu call.

<interface type='udp'>
  <mac address='52:54:00:5c:67:56'/>
  <source address='127.0.0.1' port='11112'>
    <local address='127.0.0.1' port='22222'/>
  </source>
  <model type='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</interface>

QEMU call:
-net socket,udp=127.0.0.1:11112,localaddr=127.0.0.1:22222

Notice the xml "local" entry becomes the "localaddr" for the qemu call.

reference:
http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg00629.html

Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoPost release version bump to 1.2.20
Ján Tomko [Wed, 2 Sep 2015 08:17:37 +0000 (10:17 +0200)]
Post release version bump to 1.2.20

9 years agoRelease of libvirt-1.2.19
Daniel Veillard [Wed, 2 Sep 2015 02:19:20 +0000 (10:19 +0800)]
Release of libvirt-1.2.19

* docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: regenerated

9 years agosrc: Check for symbols ordering in ADMIN_SYM_FILES
Michal Privoznik [Mon, 31 Aug 2015 10:45:16 +0000 (12:45 +0200)]
src: Check for symbols ordering in ADMIN_SYM_FILES

Like we are checking for the correct order in SYM_FILES, we
should do the same for ADMIN_SYM_FILES.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosrc: Cleanup libvirt_admin.syms
Michal Privoznik [Mon, 31 Aug 2015 09:37:45 +0000 (11:37 +0200)]
src: Cleanup libvirt_admin.syms

It's a generated file, so after 'distclean' it should be gone.
But it isn't yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosrc: Check libvirt_admin.syms for exported symbols
Michal Privoznik [Mon, 31 Aug 2015 09:35:46 +0000 (11:35 +0200)]
src: Check libvirt_admin.syms for exported symbols

We have this check rule in src/Makefile: check-symfile that
should check if all symbols we wanted to export are exported.
Moreover, if we are not exporting something more. Do the same
with libvirt_admin.syms.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoapparmor: Adjust path to domain monitor socket
Guido Günther [Sat, 29 Aug 2015 16:05:50 +0000 (18:05 +0200)]
apparmor: Adjust path to domain monitor socket

f1f68ca33 moved the monitor socket to a per domain directory. Adjust the
path accordingly.

9 years agoutil: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails
Laine Stump [Wed, 26 Aug 2015 03:19:03 +0000 (23:19 -0400)]
util: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails

commit 09778e09 switched from using ioctl(SIOCBRDELBR) for bridge
device deletion to using a netlink RTM_DELLINK message, which is the
more modern way to delete a bridge (and also doesn't require the
bridge to be ~IFF_UP to succeed). However, although older kernels
(e.g. 2.6.32, in RHEL6/CentOS6) support deleting *some* link types
with RTM_NEWLINK, they don't support deleting bridges, and there is no
compile-time way to figure this out.

This patch moves the body of the SIOCBRDELBR version of
virNetDevBridgeDelete() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_DELLINK version if the RTM_DELLINK message generates an EOPNOTSUPP
error. Since RTM_DELLINK is done from the subordinate function
virNetlinkDelLink, which is also called for other purposes (deleting a
macvtap interface), a function pointer called "fallback" has been
added to the arglist of virNetlinkDelLink() - if that arg != NULL, the
provided function will be called when (and only when) RTM_DELLINK
fails with EOPNOTSUPP.

Resolves:  https://bugzilla.redhat.com/show_bug.cgi?id=1252780 (part 2)

9 years agoutil: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails
Laine Stump [Wed, 26 Aug 2015 00:48:19 +0000 (20:48 -0400)]
util: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails

commit fc7b23db switched from using ioctl(SIOCBRADDBR) for bridge
creation to using a netlink RTM_NEWLINK message with IFLA_INFO_KIND =
"bridge", which is the more modern way to create a bridge. However,
although older kernels (e.g. 2.6.32, in RHEL6/CentOS6) support
creating *some* link types with RTM_NEWLINK, they don't support
creating bridges, and there is no compile-time way to figure this out
(since the "type" isn't an enum, but rather a character string).

This patch moves the body of the SIOCBRADDBR version of
virNetDevBridgeCreate() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_NEWLINK version if the RTM_NEWLINK message generates an EOPNOTSUPP
error.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1252780

9 years agoRevert "LXC: show used memory as 0 when domain is not active"
Jim Fehlig [Mon, 10 Aug 2015 18:49:55 +0000 (12:49 -0600)]
Revert "LXC: show used memory as 0 when domain is not active"

This reverts commit 1ce7c1d20cfd5afb26d2dbc88201085d52415d0e,
which introduced a significant semantic change to the
virDomainGetInfo() API. Additionally, the change was only
made to 2 of the 15 virt drivers.

Conflicts:
src/qemu/qemu_driver.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: acquire a job when receiving a migrating domain
Jim Fehlig [Thu, 16 Jul 2015 18:24:32 +0000 (12:24 -0600)]
libxl: acquire a job when receiving a migrating domain

Commit f86ae403 moved acquiring a job from libxlDomainStart()
to its callers. One spot missed was in libxlDoMigrateReceive().
Acquire a job in libxlDoMigrateReceive() before calling
libxlDomainStart().

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: don't attempt to resume domain when suspend fails
Jim Fehlig [Wed, 15 Jul 2015 23:29:15 +0000 (17:29 -0600)]
libxl: don't attempt to resume domain when suspend fails

Failure of libxl_domain_suspend() does not leave the domain in
a suspended state, so no need to call libxl_domain_resume(),
which btw will fail with "domain not suspended".

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: fix ref counting of libxlMigrationDstArgs
Jim Fehlig [Wed, 15 Jul 2015 22:35:50 +0000 (16:35 -0600)]
libxl: fix ref counting of libxlMigrationDstArgs

This patch fixes some flawed logic around ref counting the
libxlMigrationDstArgs object.

First, when adding sockets to the event loop with
virNetSocketAddIOCallback(), the generic virObjectFreeCallback()
was registered as a free function, with libxlMigrationDstArgs as
its parameter. A reference was also taken on
libxlMigrationDstArgs for each successful call to
virNetSocketAddIOCallback(). The rational behind this logic was
that the libxlMigrationDstArgs object had to out-live the socket
objects. But virNetSocketAddIOCallback() already takes a
reference on socket objects, ensuring their life until removed
from the event loop and unref'ed in virNetSocketEventFree(). We
only need to ensure libxlMigrationDstArgs lives until
libxlDoMigrateReceive() finishes, which can be done by simply
unref'ing libxlMigrationDstArgs at the end of
libxlDoMigrateReceive().

The second flaw was unref'ing the sockets in the failure path of
libxlMigrateReceive() and at the end of libxlDoMigrateReceive().
As mentioned above, the sockets are already unref'ed by
virNetSocketEventFree() when removed from the event loop.
Attempting to unref the socket a second time resulted in a
libvirtd crash since the socket was previously unref'ed and
disposed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoRevert "lxc: ensure setns() syscall is defined"
Michal Privoznik [Thu, 27 Aug 2015 01:01:17 +0000 (03:01 +0200)]
Revert "lxc: ensure setns() syscall is defined"

After my previous commit this commit is no longer needed.

This reverts commit eff95ac8fce8af47c0948a1c8a654b210633a350.

9 years agolxc_container: Turn lxcAttachNS into calling virProcessSetNamespaces
Michal Privoznik [Thu, 27 Aug 2015 00:59:29 +0000 (02:59 +0200)]
lxc_container: Turn lxcAttachNS into calling virProcessSetNamespaces

Now that virProcessSetNamespaces() does accept FD list in the
correct format, we can simply turn lxcAttachNS into calling
virProcessSetNamespaces().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibvirt_lxc: Claim success for --help
Michal Privoznik [Thu, 27 Aug 2015 00:21:54 +0000 (02:21 +0200)]
libvirt_lxc: Claim success for --help

So far, if libvirt_lxc binary (usually to be found under
/usr/libexec/) is run with --help, due to a missing line
and our usual functions pattern, an 'uknown' error is returned.
Yeah, the help is printed out, but we should not claim error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: Allow virProcessSetNamespaces() to have sparse FD list
Michal Privoznik [Thu, 27 Aug 2015 00:09:54 +0000 (02:09 +0200)]
util: Allow virProcessSetNamespaces() to have sparse FD list

So far, the virProcessSetNamespaces() takes an array of FDs that
it tries to set namespace on. However, in the very next commit
this array may be sparse, having some -1's in it. Teach the
function to cope with that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirt-aa-helper: Improve valid_path
Michal Privoznik [Thu, 27 Aug 2015 00:50:21 +0000 (02:50 +0200)]
virt-aa-helper: Improve valid_path

So, after some movement in virt-aa-helper, I've noticed the
virt-aa-helper-test failing. I've ran gdb (it took me a while to
realize how to do that) and this showed up immediately:

  Program received signal SIGSEGV, Segmentation fault.
  strlen () at ../sysdeps/x86_64/strlen.S:106
  106     ../sysdeps/x86_64/strlen.S: No such file or directory.
  (gdb) bt
  #0  strlen () at ../sysdeps/x86_64/strlen.S:106
  #1  0x0000555555561a13 in array_starts_with (str=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", arr=0x7fffffffd160, size=-1540438016) at security/virt-aa-helper.c:525
  #2  0x0000555555561d49 in valid_path (path=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", readonly=false) at security/virt-aa-helper.c:617
  #3  0x0000555555562506 in vah_add_path (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw", recursive=false) at security/virt-aa-helper.c:823
  #4  0x0000555555562693 in vah_add_file (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw") at security/virt-aa-helper.c:854
  #5  0x0000555555562918 in add_file_path (disk=0x5555557d4440, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", depth=0, opaque=0x7fffffffd3e0) at security/virt-aa-helper.c:931
  #6  0x00007ffff78f18b1 in virDomainDiskDefForeachPath (disk=0x5555557d4440, ignoreOpenFailure=true, iter=0x5555555628a6 <add_file_path>, opaque=0x7fffffffd3e0) at conf/domain_conf.c:23286
  #7  0x0000555555562b5f in get_files (ctl=0x7fffffffd670) at security/virt-aa-helper.c:982
  #8  0x0000555555564100 in vahParseArgv (ctl=0x7fffffffd670, argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1277
  #9  0x00005555555643d6 in main (argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1332

So I've taken look at valid_path() because it is obviously
calling array_starts_with() with malformed @size. And here's the
result: there are two variables to hold the size of three arrays
and their value is recalculated before each call of
array_starts_with(). What if we just use three variables,
initialize them and do not touch them afterwards?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolxc: Resolve Coverity RESOURCE_LEAK
John Ferlan [Thu, 27 Aug 2015 10:59:38 +0000 (06:59 -0400)]
lxc: Resolve Coverity RESOURCE_LEAK

Commit id 'c27553b6e' added a return -1 in a failure path without
the necessary VIR_FREE(stack)

9 years agoqemu: Emit correct audit message for memory hot unplug
Luyao Huang [Thu, 13 Aug 2015 14:15:28 +0000 (22:15 +0800)]
qemu: Emit correct audit message for memory hot unplug

https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3

If the qemu monitor fails to remove the memory from the guest for
any reason, the auditlog message will incorrectly use the current
actual memory (via virDomainDefGetMemoryActual) instead of the
value we were attempting to reduce to. The result is the 'new-mem'
and 'old-mem' values for the auditlog message would be identical.

This patch creates a local 'newmem' which accounts for the current
memory size minus the memory which is being removed. NB, for the
success case this results in the same value that would be returned
by virDomainDefGetMemoryActual without the need to do the math. This
follows the existing code which would subtract the size for cur_balloon.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoqemu: Emit correct audit message for memory hot plug
Luyao Huang [Thu, 13 Aug 2015 14:15:27 +0000 (22:15 +0800)]
qemu: Emit correct audit message for memory hot plug

https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3

Prior to this patch, after successfully hot plugging memory
the audit log indicated that the update failed, e.g.:

type=VIRT_RESOURCE ... old-mem=1024000 new-mem=1548288 \
exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=pts/2 res=failed

This patch will adjust where virDomainAuditMemory is called to
ensure the proper 'ret' value is used based on success or failure.

Additionally, the audit message should include the size of the
memory we were attempting to change to rather than the current
actual size. On failure to add, the message showed the same value
for old-mem and new-mem.

In order to do this, introduce a 'newmem' local which will compute
the new size based on the oldmem size plus the size of memory we
are about to add. NB: This would be the same as calling the
virDomainDefGetMemoryActual again on success, but avoids the
overhead of recalculating. Plus cur_balloon is already adjusted
by the same value, so this follows that.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoutils: Remove the logging of errors from virNetDevSendEthtoolIoctl
Moshe Levi [Tue, 18 Aug 2015 20:58:03 +0000 (23:58 +0300)]
utils: Remove the logging of errors from virNetDevSendEthtoolIoctl

This patch remove the logging of errors of ioctl api and instead
let the caller to choose what errors to log

9 years agohostdev: skip ACS check when using VFIO for device assignment
Laine Stump [Wed, 26 Aug 2015 06:04:23 +0000 (02:04 -0400)]
hostdev: skip ACS check when using VFIO for device assignment

The ACS checks are meaningless when using the more modern VFIO driver
for device assignment since VFIO has its own more complete and exact
checks, but I didn't realize that when I added support for VFIO. This
patch eliminates the ACS check when preparing PCI devices for
assignment if VFIO is being used.

This resolves:

  https://bugzilla.redhat.com/show_bug.cgi?id=1256486

9 years agolxc: ensure setns() syscall is defined
Daniel P. Berrange [Wed, 26 Aug 2015 14:52:15 +0000 (15:52 +0100)]
lxc: ensure setns() syscall is defined

Older versions of glibc don't provide the setns() syscall
function wrapper, so we must define it ourselves to prevent
build failure on old distros.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoStart daemon only after filesystems are mounted
Martin Kletzander [Tue, 25 Aug 2015 15:07:46 +0000 (17:07 +0200)]
Start daemon only after filesystems are mounted

When images are on mounted filesystems, there is no guarantee libvirtd
will start before they are mounted.  Since we want to start after both
local and remote filesystems are mounted, we need to add both local-fs
and remote-fs as targets that should precede starting libvirtd service.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirt-aa-helper: add NVRAM store file for read/write
Peter Kieser [Thu, 20 Aug 2015 17:58:59 +0000 (10:58 -0700)]
virt-aa-helper: add NVRAM store file for read/write

This is a cryptographically signed message in MIME format.

Some UEFI firmwares may want to use a non-volatile memory to store some
variables.
If AppArmor is enabled, and NVRAM store file is set currently
virt-aa-helper does
not add the NVRAM store file to the template. Add this file for
read/write when
this functionality is defined in domain XML.

Signed-off-by: Peter Kieser <peter@kieser.ca>
9 years agoFix link to page for Virtuozzo driver
Sergey Bronnikov [Wed, 26 Aug 2015 11:34:58 +0000 (14:34 +0300)]
Fix link to page for Virtuozzo driver

9 years agolxc: Inherit namespace feature
ik.nitk [Thu, 20 Aug 2015 13:46:17 +0000 (19:16 +0530)]
lxc: Inherit namespace feature

This patch adds feature for lxc containers to inherit namespaces.
This is very similar to what lxc-tools or docker provides.  Look
for "man lxc-start" and you will find that you can pass command
args as [ --share-[net|ipc|uts] name|pid ]. Or check out docker
networking option in which you can give --net=container:NAME_or_ID
as an option for sharing +namespace.

>From this patch you can add extra libvirt option to share
namespace in following way.

 <lxc:namespace>
   <lxc:sharenet type='netns' value='red'/>
   <lxc:shareipc type='pid' value='12345'/>
   <lxc:shareuts type='name' value='container1'/>
 </lxc:namespace>

The netns option is specific to sharenet. It can be used to
inherit from existing network namespace.

Co-authored: Daniel P. Berrange <berrange@redhat.com>

9 years agoqemu: Label correct per-VM path when starting
Martin Kletzander [Tue, 25 Aug 2015 08:57:56 +0000 (10:57 +0200)]
qemu: Label correct per-VM path when starting

Commit f1f68ca33433825ce0deed2d96f1990200bc6618 overused mdir_name()
event though it was not needed in the latest version, hence labelling
directory one level up in the tree and not the one it should.

If anyone with SElinux managed to try run a domain with guest agent set
up, it's highly possible that they will need to run 'restorecon -F
/var/lib/libvirt/qemu/channel/target' to fix what was done.

Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Update blkio.weight value after successful set
Luyao Huang [Wed, 19 Aug 2015 03:56:33 +0000 (11:56 +0800)]
qemu: Update blkio.weight value after successful set

https://bugzilla.redhat.com/show_bug.cgi?id=1253107

Make a call virCgroupGetBlkioWeight to re-read blkio.weight right
after it is set in order to keep internal data up-to-date.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoRename page about vz driver
Sergey Bronnikov [Fri, 21 Aug 2015 21:44:11 +0000 (00:44 +0300)]
Rename page about vz driver

9 years agodocs: Rename 'parallels' to 'vz'
Sergey Bronnikov [Fri, 21 Aug 2015 21:43:48 +0000 (00:43 +0300)]
docs: Rename 'parallels' to 'vz'

Parallels driver was renamed to Virtuozzo. Replace old name by new
one for libvirt docs and schemas.

9 years agoEliminate incorrect and unnecessary check for changed IP address
Vasiliy Tolstov [Sat, 22 Aug 2015 15:33:15 +0000 (15:33 +0000)]
Eliminate incorrect and unnecessary check for changed IP address

Commit aa2cc7 modified a previously unnecessary but innocuous check
for interface IP address during interface update incorrectly, causing
all attempted updates (e.g. changing link state) to interfaces of
type='ethernet' for QEMU to fail.

This patch fixes the issue by completely removing the check for IP
address, which is pointless since QEMU doesn't support setting
interface IP addresses from the domain interface XML anyway.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Signed-off-by: Laine Stump <laine@laine.org>
9 years agovirDomainRename: Extend API documentation
Tomas Meszaros [Tue, 18 Aug 2015 20:22:07 +0000 (22:22 +0200)]
virDomainRename: Extend API documentation

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agoqemu: add a check for nodeset in qemuDomainSetNumaParamsLive
Luyao Huang [Fri, 14 Aug 2015 09:37:28 +0000 (17:37 +0800)]
qemu: add a check for nodeset in qemuDomainSetNumaParamsLive

We will try to set the node to cpuset.mems without check if
it is available, since we already have helper to check this.
Call virNumaNodesetIsAvailable to check if node is available,
then try to change it in the cgroup.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoselinux: fix compile errors
Guido Günther [Mon, 24 Aug 2015 12:04:37 +0000 (14:04 +0200)]
selinux: fix compile errors

Remove unused variable, tag unused parameter and adjust return type.

introduced by 3f48345f7ec0c44b8ce2371cab454d2118f830b4

CC     security/libvirt_security_manager_la-security_selinux.lo
security/security_selinux.c: In function 'virSecuritySELinuxDomainSetDirLabel':
security/security_selinux.c:2520:5: error: return makes pointer from integer without a cast [-Werror]
security/security_selinux.c:2514:9: error: unused variable 'ret' [-Werror=unused-variable]
security/security_selinux.c:2509:59: error: unused parameter 'mgr' [-Werror=unused-parameter]

9 years agostorage: only run safezero if allocation is > 0
Guido Günther [Sun, 23 Aug 2015 20:03:54 +0000 (22:03 +0200)]
storage: only run safezero if allocation is > 0

While a zero allocation in safezero should be fine it isn't when we use
posix_fallocate which returns EINVAL on a zero allocation.

While we could skip the zero allocation in safezero_posix_fallocate it's
an optimization to do it for all allocations.

This fixes vm installation via virtinst for me which otherwise aborts
like:

   Starting install...
   Retrieving file linux...               | 5.9 MB     00:01 ...
   Retrieving file initrd.gz...           |  29 MB     00:07 ...
   ERROR    Couldn't create storage volume 'virtinst-linux.sBgds4': 'cannot fill file '/var/lib/libvirt/boot/virtinst-linux.sBgds4': Invalid argument'

The error was introduced by e30297b0 as spotted by Chunyan Liu

9 years agovirt-aa-helper: allow access to /usr/share/ovmf/
intrigeri [Fri, 21 Aug 2015 08:52:52 +0000 (10:52 +0200)]
virt-aa-helper: allow access to /usr/share/ovmf/

We forbid access to /usr/share/, but (at least on Debian-based systems)
the Open Virtual Machine Firmware files needed for booting UEFI virtual
machines in QEMU live in /usr/share/ovmf/. Therefore, we need to add
that directory to the list of read only paths.

A similar patch was suggested by Jamie Strandboge <jamie@canonical.com>
on https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1483071.

9 years agovirt-aa-helper: Simplify restriction logic
Guido Günther [Fri, 21 Aug 2015 08:49:15 +0000 (10:49 +0200)]
virt-aa-helper: Simplify restriction logic

First check overrides, then read only files then restricted access
itself.

This allows us to mark files for read only access whose parents were
already restricted for read write.

Based on a proposal by Martin Kletzander

9 years agovirt-aa-helper: document --probing and --dry-run
Guido Günther [Fri, 21 Aug 2015 10:29:25 +0000 (12:29 +0200)]
virt-aa-helper: document --probing and --dry-run

9 years agotests: Use qemuProcessPrepareMonitorChr in qemuxmlnstest
Martin Kletzander [Thu, 13 Aug 2015 09:00:48 +0000 (11:00 +0200)]
tests: Use qemuProcessPrepareMonitorChr in qemuxmlnstest

The output of that function was not tested until now.  In order to keep
the paths in /tmp, the test driver config is "fixed" as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Fix access to auto-generated socket paths
Martin Kletzander [Fri, 7 Aug 2015 12:42:31 +0000 (14:42 +0200)]
qemu: Fix access to auto-generated socket paths

We are automatically generating some socket paths for domains, but all
those paths end up in a directory that's the same for multiple domains.
The problem is that multiple domains can each run with different
seclabels (users, selinux contexts, etc.).  The idea here is to create a
per-domain directory labelled in a way that each domain can access its
own unix sockets.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1146886

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_dac: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:15:58 +0000 (11:15 -0700)]
security_dac: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_selinux: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:07:07 +0000 (11:07 -0700)]
security_selinux: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_stack: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:01:12 +0000 (11:01 -0700)]
security_stack: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity: Add virSecurityDomainSetDirLabel
Martin Kletzander [Mon, 17 Aug 2015 17:43:43 +0000 (10:43 -0700)]
security: Add virSecurityDomainSetDirLabel

That function can be used for setting security labels on arbitrary
directories.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_dac: Label non-listening sockets
Martin Kletzander [Thu, 13 Aug 2015 05:36:30 +0000 (07:36 +0200)]
security_dac: Label non-listening sockets

SELinux security driver already does that, but DAC driver somehow missed
the memo.  Let's fix it so it works the same way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_selinux: Use proper structure to access socket data
Martin Kletzander [Thu, 13 Aug 2015 05:35:10 +0000 (07:35 +0200)]
security_selinux: Use proper structure to access socket data

In virSecuritySELinuxSetSecurityChardevLabel() we are labelling unix
socket path, but accessing another structure of the union.  This does
not pose a problem currently as both paths are at the same offset, but
this should be fixed for the future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolocking: Remove redundant 'srv' element from virLockDaemon
Erik Skultety [Thu, 20 Aug 2015 14:56:32 +0000 (16:56 +0200)]
locking: Remove redundant 'srv' element from virLockDaemon

Now that we have virNetDaemon object holding all the data and being
capable of referencing multiple servers, having a duplicate reference to
a single server stored in virLockDaemon isn't necessary anymore. This
patch removes the above described element.

9 years agotest: Replace tabs with spaces in virnetdaemondata json files
Erik Skultety [Thu, 6 Aug 2015 13:33:58 +0000 (15:33 +0200)]
test: Replace tabs with spaces in virnetdaemondata json files

JSON data that are used to initialize tests in virnetdaemontest should
be in a consistent format, i.e. not using tabs for indentation, those
should be replaced by spaces.

9 years agotests: Add some compatibility-related cases to the CPU tests
Andrea Bolognani [Fri, 14 Aug 2015 14:45:18 +0000 (16:45 +0200)]
tests: Add some compatibility-related cases to the CPU tests

9 years agocpu: Move check for NULL CPU model inside the driver
Andrea Bolognani [Fri, 14 Aug 2015 14:04:18 +0000 (16:04 +0200)]
cpu: Move check for NULL CPU model inside the driver

While the check is appropriate for eg. the x86 and generic drivers,
there are some valid ppc64 guest configurations where the CPU
model is supposed to be NULL.

Moving this check from the generic code to the drivers makes it
possible to accomodate both use cases.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927

9 years agocpu: Better support for ppc64 compatibility modes
Andrea Bolognani [Thu, 13 Aug 2015 15:50:37 +0000 (17:50 +0200)]
cpu: Better support for ppc64 compatibility modes

Not all combinations of host CPU models and compatibility modes
are valid, so we need to make sure we don't try to do something
that QEMU will reject.

Moreover, we need to apply a different logic to guests using
host-model and host-passthrough modes when testing them for host
compatibility.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927

9 years agocpu: Don't update host-model guest CPUs on ppc64
Andrea Bolognani [Thu, 13 Aug 2015 11:40:12 +0000 (13:40 +0200)]
cpu: Don't update host-model guest CPUs on ppc64

If a guest CPU is defined using

  <cpu mode='host-model'/>

the <model> sub-element will contain the compatibility mode to use.
That means we can't just copy the host CPU model on cpuUpdate(),
otherwise we'll overwrite that information and migration of such
guests will fail.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1251927

9 years agoAdd generated libvirt_admin.syms into .gitignore
Martin Kletzander [Thu, 20 Aug 2015 18:03:12 +0000 (11:03 -0700)]
Add generated libvirt_admin.syms into .gitignore

Commit a2c5d16a70a6161449c687be74db2813b362cf5e switched to generating
libvirt_admin.syms, but forgot to add the generated file into
.gitignore, hence causing tree pollution post-build.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Check for attach disk usage of iothread=0
John Ferlan [Wed, 12 Aug 2015 19:02:47 +0000 (15:02 -0400)]
conf: Check for attach disk usage of iothread=0

Since iothreadid = 0 is invalid, we need to check for it when attempting
to add a disk; otherwise, someone would think/believe their attempt to
add an IOThread to the disk would succeed. Luckily other code ignored
things when ->iothread == 0...

9 years agodocs: Drop unused rule for internals/%.html.tmp target
Guido Günther [Wed, 19 Aug 2015 10:35:31 +0000 (12:35 +0200)]
docs: Drop unused rule for internals/%.html.tmp target

We're using the %.html.tmp for all html files now so drop the unused one
and rather make sure the needed directory exists.

This fixes build failures as described in

    https://www.redhat.com/archives/libvir-list/2015-August/msg00603.html

9 years agolibvirt-admin: Generate symbols file
Guido Günther [Wed, 19 Aug 2015 08:38:31 +0000 (10:38 +0200)]
libvirt-admin: Generate symbols file

Since we're linking this into libvirtd we need some symbols to be public
but not part of the public API so mark them as
LIBVIRT_ADMIN_PRIVATE_<VERSION> as we do with libvirt.

Making all other symbols local makes sure we don't accidentally leak
unwanted ones.

9 years agodaemon: Use $(NULL) for libvird_admin's flags
Guido Günther [Wed, 19 Aug 2015 08:27:25 +0000 (10:27 +0200)]
daemon: Use $(NULL) for libvird_admin's flags

This makes it consistent with the other FLAGS in this file and reduced
clutter in the diff when adding new entries.

9 years agoutil: fix build without cgroup
Roman Bogorodskiy [Thu, 20 Aug 2015 06:42:56 +0000 (09:42 +0300)]
util: fix build without cgroup

Commit 89c509a0 added getters for cgroup block device I/O throttling,
however stub versions of these functions have not matching function
prototypes that result in compilation fail on platforms not supporting
cgroup.

Fix build by correcting prototypes of the stubbed functions.

Pushing under build-breaker rule.

9 years agovirconf: correct code formatting
Cao jin [Mon, 17 Aug 2015 12:42:03 +0000 (20:42 +0800)]
virconf: correct code formatting

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agovirConfWalk: fix the inconsistent name
Cao jin [Wed, 19 Aug 2015 02:36:28 +0000 (10:36 +0800)]
virConfWalk: fix the inconsistent name

Fix inconsistency between function description and actual
parameter name.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agoqemu: Report better error message when renaming to existing domain name
Martin Kletzander [Tue, 18 Aug 2015 18:22:02 +0000 (11:22 -0700)]
qemu: Report better error message when renaming to existing domain name

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Sync BlkioDevice values when setting them in cgroups
Martin Kletzander [Mon, 3 Aug 2015 13:56:20 +0000 (15:56 +0200)]
qemu: Sync BlkioDevice values when setting them in cgroups

The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1165580

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolxc: Sync BlkioDevice values when setting them in cgroups
Martin Kletzander [Mon, 3 Aug 2015 13:56:08 +0000 (15:56 +0200)]
lxc: Sync BlkioDevice values when setting them in cgroups

The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add getters for cgroup block device I/O throttling
Martin Kletzander [Mon, 3 Aug 2015 13:10:20 +0000 (15:10 +0200)]
util: Add getters for cgroup block device I/O throttling

Since now they were not needed, but I sense they will be in a short
while.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add virCgroupGetBlockDevString
Martin Kletzander [Mon, 3 Aug 2015 12:44:14 +0000 (14:44 +0200)]
util: Add virCgroupGetBlockDevString

This function translates device paths to "major:minor " string, and all
virCgroupSetBlkioDevice* functions are modified to use it.  It's a
cleanup with no functional change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add virStringGetFirstWithPrefix
Martin Kletzander [Mon, 3 Aug 2015 12:03:23 +0000 (14:03 +0200)]
util: Add virStringGetFirstWithPrefix

That function takes string list and returns first string in that list
that starts with the @prefix parameter with that prefix being skipped as
the caller knows what it starts with (also for easier manipulation in
future).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemuDomainRename: Don't leave a domain locked uppon fail
Michal Privoznik [Tue, 18 Aug 2015 18:40:56 +0000 (20:40 +0200)]
qemuDomainRename: Don't leave a domain locked uppon fail

Well, yet again one case of 'goto cleanup' while 'goto endjob'
was needed. Sorry.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Add check for invalid iothread_id in qemuDomainChgIOThread
John Ferlan [Thu, 13 Aug 2015 13:19:01 +0000 (09:19 -0400)]
qemu: Add check for invalid iothread_id in qemuDomainChgIOThread

https://bugzilla.redhat.com/show_bug.cgi?id=1251886

Since iothread_id == 0 is an invalid value for QEMU let's point
that out specifically.  For the IOThreadDel code, the failure would
have ended up being a failure to find the IOThread ID; however, for
the IOThreadAdd code - an IOThread 0 was added and that isn't good.

It seems during many reviews/edits to the code the check for
iothread_id = 0 being invalid was lost - it could have originally
been in the API code, but requested to be moved - I cannot remember.

9 years agoapi: Adjust comment for virDomainAddIOThread
John Ferlan [Thu, 13 Aug 2015 13:18:48 +0000 (09:18 -0400)]
api: Adjust comment for virDomainAddIOThread

The comment for the function indicated that iothread_id had to be
a positive non-zero value; however, that wasn't checked - that is
a value of 0 is/was allowed by the API and was left up to the
hypervisor to reject the value.

More than likely this nuance was missed during the many "adjustments"
to the API in the review phase.

9 years agoapi: Remove check on iothread_id arg in virDomainPinIOThread
John Ferlan [Thu, 13 Aug 2015 12:44:32 +0000 (08:44 -0400)]
api: Remove check on iothread_id arg in virDomainPinIOThread

Allow 0 as an iothread_id and force the hypervisor to handle.
The qemuDomainPinIOThread API will look up the iothread_id of
0 and not find it and message that anyway.

9 years agoqemuDomainAddCgroupForThread: Don't overwrite the error
Luyao Huang [Fri, 14 Aug 2015 06:59:54 +0000 (14:59 +0800)]
qemuDomainAddCgroupForThread: Don't overwrite the error

Just like in commit 704cf06, if virCgroup*() fails, the error is
already reported. There's no need to overwrite the error with a
generic one and possibly hiding the true root cause of the error.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agovirconf: fix the inconsistent name
Cao jin [Tue, 18 Aug 2015 12:38:07 +0000 (20:38 +0800)]
virconf: fix the inconsistent name

Fix inconsistency between function description and actual
parameter name in virConfGetValue/virConfSetValue.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agovirsh: Reset global error after successfull domain lookup
Luyao Huang [Mon, 17 Aug 2015 09:56:48 +0000 (17:56 +0800)]
virsh: Reset global error after successfull domain lookup

When looking up a domain, we try to look up by ID, UUID and NAME
consequently while not really caring which of those lookups succeeds.
The problem is that if any of them fails, we dispatch the error from the
driver and that means setting both threadlocal and global error. Let's
say the last lookup (by NAME) succeeds and resets the threadlocal error as any
other API does, however leaving the global error unchanged. If the underlying
virsh command does not succeed afterwards, our cleanup routine in
vshCommandRun ensures that no libvirt error will be forgotten and that's
exactly where this global error comes in incorrectly.

 # virsh domif-setlink 123 vnet1 up
 error: interface (target: vnet1) not found
 error: Domain not found: no domain with matching id 123

This patch also resets the global error which would otherwise cause some
minor confusion in reported error messages.

https://bugzilla.redhat.com/show_bug.cgi?id=1254152

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agobuild: fix mingw build
Eric Blake [Mon, 17 Aug 2015 23:03:40 +0000 (16:03 -0700)]
build: fix mingw build

Ever since commit e44b0269, 64-bit mingw compilation fails with:

../../src/util/virprocess.c: In function 'virProcessGetPids':
../../src/util/virprocess.c:628:50: error: passing argument 4 of 'virStrToLong_i' from incompatible pointer type [-Werror=incompatible-pointer-types]
         if (virStrToLong_i(ent->d_name, NULL, 10, &tmp_pid) < 0)
                                                  ^
In file included from ../../src/util/virprocess.c:59:0:
../../src/util/virstring.h:53:5: note: expected 'int *' but argument is of type 'pid_t * {aka long long int *}'
 int virStrToLong_i(char const *s,
     ^
cc1: all warnings being treated as errors

Although mingw won't be using this function, it does compile the
file, and the fix is relatively simple.

* src/util/virprocess.c (virProcessGetPids): Don't assume pid_t
fits in int.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agoqemuDomainRename: Explicitly check if domain is renaming to itself
Michal Privoznik [Fri, 14 Aug 2015 13:36:05 +0000 (15:36 +0200)]
qemuDomainRename: Explicitly check if domain is renaming to itself

It may happen that user (mistakenly) wants to rename a domain to
itself. Which is no renaming at all. We should reject that with
some meaningful error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirHashAddEntry: Report error on duplicate key
Michal Privoznik [Mon, 17 Aug 2015 19:01:07 +0000 (21:01 +0200)]
virHashAddEntry: Report error on duplicate key

If this function fails, the error message is reported only in
some cases (e.g. OOM), but in some it's not (e.g. duplicate key).
This fact is painful and we should either not report error at all
or report the error in all possible cases. I vote for the latter.
Unfortunately, since the key may be an arbitrary value (not
necessarily a string) we can't report it in the error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirHashAddOrUpdateEntry: Turn @new_name into void *
Michal Privoznik [Mon, 17 Aug 2015 19:07:40 +0000 (21:07 +0200)]
virHashAddOrUpdateEntry: Turn @new_name into void *

In 9190f0b0 we've tried to fix an OOM. And boy, was that fix
successful. But back then, the hash table implementation worked
strictly over string keys, which is not the case anymore. Hash
table have this function keyCopy() which returns void *.
Therefore a local variable that is temporarily holding the
intermediate return value from that function should be void *
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibvirt-domain: forbid use virDomainRename in readonly connection
Luyao Huang [Mon, 17 Aug 2015 05:22:00 +0000 (13:22 +0800)]
libvirt-domain: forbid use virDomainRename in readonly connection

This function will change the guest name, we shouldn't
allow the readonly user do this.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agovirsh: fix always return false in domrename
Luyao Huang [Mon, 17 Aug 2015 05:21:59 +0000 (13:21 +0800)]
virsh: fix always return false in domrename

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoqemu: Resolve Coverity UNINIT
John Ferlan [Sat, 15 Aug 2015 13:15:42 +0000 (09:15 -0400)]
qemu: Resolve Coverity UNINIT

Coverity complained that 'vm' wasn't initialized before jumping to
cleanup: and calling virDomainObjEndAPI if the VIR_STRDUP fails.
So I initialized vm = NULL and also moved the VIR_STRDUP closer to
usage and used endjob for goto. Lots of other reasons for failures.

9 years agoprotocol: Don't use rename as a variable name
Martin Kletzander [Sat, 15 Aug 2015 14:44:38 +0000 (16:44 +0200)]
protocol: Don't use rename as a variable name

That causes shadowing errors on older compilers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRemove static keyword from vshReadline when readline does not exist
Moshe Levi [Sat, 15 Aug 2015 07:59:41 +0000 (10:59 +0300)]
Remove static keyword from vshReadline when readline does not exist

This patch removes the static keyword from the vshReadline which was
introduced in commit 834c5720e4434f0bcc807bb1cf20855af63e24a3. With
readline the vshReadline function is not static but when compiling
without readline it was defined as static which caused compilation
error.

9 years agotools: Introduce new client generic module vsh
Erik Skultety [Mon, 15 Jun 2015 16:53:58 +0000 (18:53 +0200)]
tools: Introduce new client generic module vsh

In order to share as much virsh' logic as possible with upcomming
virt-admin client we need to split virsh logic into virsh specific and
client generic features.

Since majority of virsh methods should be generic enough to be used by
other clients, it's much easier to rename virsh specific data to virshX
than doing this vice versa. It moved generic virsh commands (including info
and opts structures) to generic module vsh.c.

Besides renaming methods and structures, this patch also involves introduction
of a client specific control structure being referenced as private data in the
original control structure, introduction of a new global vsh Initializer,
which currently doesn't do much, but there is a potential for added
functionality in the future.
Lastly it introduced client hooks which are especially necessary during
client connecting phase.

9 years agoqemu: Implement virDomainRename
Tomas Meszaros [Mon, 10 Aug 2015 19:59:18 +0000 (21:59 +0200)]
qemu: Implement virDomainRename

Currently supports only renaming inactive domains without snapshots.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoIntroduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED event
Tomas Meszaros [Mon, 10 Aug 2015 19:59:17 +0000 (21:59 +0200)]
Introduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED event

This should be emitted whenever a domain is renamed.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agodomain_conf: Introducde virDomainObjListRenameAddNew() & virDomainObjListRenameRemove()
Tomas Meszaros [Mon, 10 Aug 2015 19:59:16 +0000 (21:59 +0200)]
domain_conf: Introducde virDomainObjListRenameAddNew() & virDomainObjListRenameRemove()

We just need to update the entry in the second hash table. Since commit 8728a56
we have two hash tables for the domain list so that we can do O(1) lookup
regardless of looking up by UUID or name. Since with renaming a domain UUID does
not change, we only need to update the second hash table, where domains are
referenced by their name.

We will call both functions from the qemuDomainRename().

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agovirsh: Implement "domrename" command
Tomas Meszaros [Mon, 10 Aug 2015 19:59:15 +0000 (21:59 +0200)]
virsh: Implement "domrename" command

This patch implements new virsh command, domrename.

Using domrename, it will be possible to rename domain from the virsh shell by
calling virRenameDomain API.

It takes two arguments, current domain name and new domain name.

Example:

virsh # list --all
 Id    Name                           State
 ----------------------------------------------------
  -     bar                            shut off

virsh # domrename bar foo
Domain successfully renamed

virsh # list --all
 Id    Name                           State
 ----------------------------------------------------
  -     foo                            shut off

virsh #

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agoIntroduce virDomainRename API
Tomas Meszaros [Mon, 10 Aug 2015 19:59:14 +0000 (21:59 +0200)]
Introduce virDomainRename API

Also, among with this new API new ACL that restricts rename
capability is invented too.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoDetect location of qemu-bridge-helper
Guido Günther [Thu, 13 Aug 2015 10:20:29 +0000 (12:20 +0200)]
Detect location of qemu-bridge-helper

RedHat and Debian based distros use different locations

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=790935