Commit Graph

1591 Commits

Author SHA1 Message Date
Martin Kletzander
dc56475f72 nss: Make aligning look nicer
Every aligning requires at least one cast and it's hard to read.  Let's
make a function that makes sure the pointer is moved according to the
alignment and use that to move throughout the data buffer.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-21 20:55:00 +01:00
Cristian Klein
4cdc4a76d3 virsh: Add --postcopy-after-precopy option to migrate
Signed-off-by: Cristian Klein <cristiklein@gmail.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
257060349e virsh: Configurable migrate --timeout action
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Cristian Klein
179d97283f virsh: Add support for post-copy migration
Signed-off-by: Cristian Klein <cristiklein@gmail.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
5a9cbc6265 Add event and state details for post-copy
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY and VIR_DOMAIN_PAUSED_POSTCOPY are
used on the source host once migration enters post-copy mode (which
means the domain gets paused on the source. After the destination host
takes over the execution of the domain, its virtual CPUs are resumed and
the domain enters VIR_DOMAIN_RUNNING_POSTCOPY state and
VIR_DOMAIN_EVENT_RESUMED_POSTCOPY event is emitted.

In case migration fails during post-copy mode and none of the hosts have
complete state of the domain, both domains will remain paused with
VIR_DOMAIN_PAUSED_POSTCOPY_FAILED reason and an upper layer may decide
what to do.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Roman Bogorodskiy
ae33a7b336 nss: don't try to build nss plugin when disabled
Even if nss is disabled, the build system tries to build some
targets like libnss_libvirt_impl.la and nsstest. Hide those
under the "if WITH_NSS" block like the rest of NSS plugin bits.
2016-03-20 18:44:35 +03:00
Michal Privoznik
917038c110 Implement _nss_libvirt_gethostbyname4_r
This function is a different beast compared to previous ones.
But yet again, nothing surprising is happening here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
7dbcb26f7f nss: Implement _nss_libvirt_gethostbyname3_r
The implementation is pretty straightforward. Moreover, because
of the nature of things, gethostbyname_r and gethostbyname2_r can
be implemented at the same time too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
859cb18d54 Initial support for NSS plugin skeleton
Name Service Switch is a glibc feature responsible for many
things. Translating domain names into IP addresses and vice versa
is just one of them. However, currently it's the only
functionality that this commit is tickling. Well, in this commit
the plugin skeleton is introduced. Implementation to come in next
patches.
Because of the future testing, where the implementation is to be
linked with a test, this needs to go into static library. Linking
a program with an .so statically is not portable. Therefore a
dummy libnss_libvirt_impl library is being introduced too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Nikolay Shirokovskiy
f486cb5ea0 migration: add target peer disks port
Some hypervisors (namely qemu) can have a separate connecton for
non-shared disks migration of active domains. Currently we have
no means to control the port of such a connection. At the same
time we have options to control port of memory migration traffic
(thru migration uri) as well as interfaces that target server
is bound to for incoming migration (thru VIR_MIGRATE_PARAM_LISTEN_ADDRESS).
Let's add the option for setting disks port too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-17 16:20:15 +01:00
Dmitry Andreev
8047d45704 Introduce new VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT sub-event
VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT event should be emitted
when domain configuration was changed on revert to snapshot.
2016-03-15 14:57:26 -04:00
Martin Kletzander
9d479dd185 virt-admin: Don't tell everyone needlessly we're connected
There are cases when we don't want to tell the user we are connected.
That's for example when we first connect to the server without the
command 'connect' itself.  That helps to clear out output of first
command, mainly when running non-interactively.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
724d5340bd virt-admin: Don't leak uri in cmdSrvList
virAdmConnectGetURI() returns string that needs to be free()'d but we
haven't done that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Peter Krempa
e7e6980dd8 virsh: vcpupin: Ask for pinning info for all vCPUs
The API docs state that the API queries pinning info for all vCPUs and
thus we should allocate the bitmap even for the inactive ones.

The API will currently return bitmap only for the active vCPUs but that
will change in the future.
2016-03-09 10:09:16 +01:00
Jiri Denemark
f289300181 Introduce job completed event
The VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event will be triggered once a job
(such as migration) finishes and it will contain statistics for the job
as one would get by calling virDomainGetJobStats. Thanks to this event
it is now possible to get statistics of a completed migration of a
transient domain on the source host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Ján Tomko
34111a60f8 tools: do not leak uri in disconnect handler
Commit 035947e introduced a call to virConnectGetURI
without a matching free() in virshCatchDisconnect.

Also fix vshAdmCatchDisconnect where it was copied by
commit 6dd7e42.

https://bugzilla.redhat.com/show_bug.cgi?id=1303891
2016-03-04 08:08:16 +01:00
John Ferlan
ea48397b01 virsh: Add support for text based polkit authentication
https://bugzilla.redhat.com/show_bug.cgi?id=872166

When the login session doesn't have an ssh -X type display agent in
order for libvirtd to run the polkit session authentication, attempts
to run 'virsh -c qemu:///system list' from an unauthorized user (or one
that isn't part of the libvirt /etc/group) will fail with the following
error from libvirtd:

error: authentication unavailable: no polkit agent available to
       authenticate action 'org.libvirt.unix.manage'

In order to handle the local authentication, we will use the new
virPolkitAgentCreate API in order to create a text based authentication
agent for our non readonly session to authenticate with.

The new code will execute in a loop allowing 5 failures to authenticate
before failing out.

With this patch in place, the following occurs:

$ virsh -c qemu:///system list
==== AUTHENTICATING FOR org.libvirt.unix.manage ===
System policy prevents management of local virtualized systems
Authenticating as: Some User (SUser)
Password:
==== AUTHENTICATION COMPLETE ===
 Id    Name                           State
 ----------------------------------------------------
  1     somedomain                     running

$
2016-03-01 06:50:16 -05:00
Nitesh Konkar
2652757070 virsh: reject migration with both --live and --offline
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2016-02-26 12:45:20 +01:00
Michal Privoznik
4a3ae388ba cmdSaveImageEdit: Prefer VSH_EXCLUSIVE_OPTIONS over by hand check
Since we have the macro there's no need for us to unwind it by
hand and check for mutually exclusive flags ourselves.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-22 16:56:07 +01:00
Michal Privoznik
6dce0b3016 cmdNetworkUpdate: Prefer VSH_EXCLUSIVE_OPTIONS over if-else tree
We have macros that check and reject mutually exclusive
parameters to our commands. Use those instead of if-else tree.
At the same time, the variable @current becomes useless therefore
it is dropped.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-22 16:55:33 +01:00
Peter Krempa
773f3bd3cc virsh: cpupin: Extract getter code into a separate function 2016-02-19 15:24:54 +01:00
Peter Krempa
a7bc9841a4 virsh: cmdVcpuPin: Simplify handling of API flags
Rather than setting flags to -1 if none were specified, move the logic
to use the old API to the place where we need to decide. It simplifies
the logic a bit.
2016-02-19 15:13:21 +01:00
Ján Tomko
b4c6fa4418 vsh: use virBufferTrim in vshOutputLogFile
Use virBufferTrim to strip the extra newline at the end
of the message instead of open-coding it after the buffer's
string is formatted.
2016-02-18 16:18:22 +01:00
Peter Krempa
3ad5186ed3 virsh: Remove <backingStore> when changing cdrom media source
Since the code is changing the source image path by modifying the
existing XML snippet the <backingStore> stays in place.

As <backingStore> is relevant to the <source> part of the image, the
update of that part makes the element invalid.

CD/floppy images usually don't have a backing chain and the element is
currently ignored though but it might start being used in the future so
let's start behaving correctly.

Drop the <backingStore> subtree once we want to update the XML.

Before this patch, you'd get:
$ virsh change-media --eject --print-xml 10 hdc
<disk type="file" device="cdrom">
      <driver name="qemu" type="qcow2"/>

      <backingStore type="file" index="1">
        <format type="qcow2"/>
        <source file="/var/lib/libvirt/images/vm.1436949097"/>
        <backingStore/>
      </backingStore>
      <target dev="hdc" bus="ide"/>
      ...
    </disk>

After:

 $ virsh change-media --eject --print-xml 10 hdc
<disk type="file" device="cdrom">
      <driver name="qemu" type="qcow2"/>

      <target dev="hdc" bus="ide"/>
      ...
    </disk>
2016-02-18 09:50:45 +01:00
Erik Skultety
2c21e5b592 virt-admin: Introduce cmdSrvList
Since we introduced listing API earlier in these series, it's time
to wire up the API to the virt-admin client.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-02-17 12:46:34 +01:00
Ján Tomko
d616544077 Spell VMware with a lowercase w
Replace all occurrences of VMWare outside the news.
2016-02-15 15:35:48 +01:00
Peter Krempa
27fa42b24c vsh: Replace vshPrint macro with function
The macro would eat the first parameter. In some cases the format string
for vshPrint was eaten. In other cases the calls referenced variables
which did not exist in the given context. Avoid errors by doing compile
time checking.
2016-02-15 13:31:12 +01:00
Peter Krempa
018010f05c vsh: Simplify bailing out on OOM conditions
When we hit OOM it doesn't really make sense to format the error message
by attempting to allocate it. Introduce a simple helper that prints a
static message and terminates the execution.
2016-02-15 13:31:12 +01:00
Michal Privoznik
64e66d8ed6 virsh: Teach vol-create-as to --print-xml
We have the same argument to many other commands that produce an
XML based on what user typed. But unfortunately vol-create-as
was missing it. Maybe nobody had needed it yet. Well, I did
just now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-12 16:16:09 +01:00
Michal Privoznik
bb0b8e5d67 cmdVolCreateAs: Rework to follow usual func pattern
The way we usually write functions is that we start the work and
if something goes bad we goto cleanup and roll back there. Or
just free resources that are no longer needed. Do the same here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-02-12 16:16:09 +01:00
Roman Bogorodskiy
6221b8944e virsh: display if ZFS storage backend is enabled
Make 'virsh -V' list ZFS storage backend if it's enabled.
2016-02-04 03:16:50 +03:00
Michael Chapman
86c4df83b9 virsh: improve waiting for block job readiness
After a block job hits 100%, we only need to apply a timeout waiting for
a block job event if exactly one of the BLOCK_JOB or BLOCK_JOB_2
callbacks were able to be registered.

If neither callback could be registered, there's clearly no need for a
timeout.

If both callbacks were registered, then we're guaranteed to eventually
get one of the events. The path being used by virsh must be exactly the
source path or target device in the domain's disk definition, and these
are the respective strings sent back in these two events.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Michael Chapman
8fa216bbb4 virsh: ensure SIGINT action is reset on all errors
If virTimeMillisNow() fails, the SIGINT action must be reset back to
its previous state.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Michael Chapman
15dee2ef24 virsh: be consistent with style of loop exit
When waiting for a block job, the various statuses (COMPLETED, READY,
CANCELED, etc.) should all be treated consistently by having the loop be
exited with "break". Use "goto cleanup" for the error cases only, when
no block job status is available.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Michael Chapman
704dfd6b0f virsh: avoid unnecessary progress updates
There is no need to call virshPrintJobProgress() unless the block job's
cur or end cursors have changed since the last iteration.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
2016-02-01 18:04:48 +01:00
Wido den Hollander
63cdc92f04 storage: Add TRIM algorithm to storage volume API
This new algorithm adds support for wiping volumes using TRIM.

It does not overwrite all the data in a volume, but it tells the
backing storage pool/driver that all bytes in a volume can be
discarded.

It depends on the backing storage pool how this is handled.

A SCSI backend might send UNMAP commands to remove all data present
on a LUN.

A Ceph backend might use rbd_discard() to instruct the Ceph cluster
that all data on that RBD volume can be discarded.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2016-01-29 11:09:14 -05:00
Luyao Huang
985f01a65f virsh: fix cpu-stats command output format issue
After commit 57177f1, the cpu-stats command format change to:

CPU0:
    cpu_time         14401.507878990 seconds
    vcpu_time    14378732785511

vcpu_time is not user friendly. After this patch, it will
change back:
CPU0:
    cpu_time         14401.507878990 seconds
    vcpu_time        14378.732785511 seconds

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2016-01-26 09:23:49 +01:00
Peter Krempa
a2e80549a2 virsh: cpu-stats: Remove unneeded flags
virDomainGetCPUStats doesn't support flags so there's no need to carry
the 'flags' variable around. Additionally since the API is poorly
designed I doubt that it will be extended.
2016-01-25 17:45:09 +01:00
Peter Krempa
57177f1abd virsh: cpu-stats: Extract common printing code into a function
Simplify the code by extracting a common code path.
2016-01-25 17:45:09 +01:00
Michal Privoznik
99f8fb4c55 virt-host-validate: Fix error level for user namespace check
From the code it seems to me that we need user namespace if
configured in domain XML. Otherwise we don't use it at all.
However our tool is more strict about that. Fix this discrepancy.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-25 16:53:23 +01:00
Michal Privoznik
d55e11a302 virt-host-validate: Check those CGroups that we actually use
Since the introduction of virt-host-validate tool the set of
cgroup controllers we use has changed so the tool is checking for
some cgroups that we don't need (e.g. net_cls, although I doubt
we have ever used that one) and is not checking for those we
actually use (e.g. cpuset).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-25 16:53:18 +01:00
Michal Privoznik
9cbd1ecc3e virsh: Correctly detect inserted media in change-media command
https://bugzilla.redhat.com/show_bug.cgi?id=1250331

It all works like this. The change-media command dumps domain
XML, finds the corresponding cdrom device we want to change media
in and returns it in the xmlNodePtr form. This way we don't have
to bother with keeping all the subelements or attributes that we
don't care about in the XML that is fed back to libvirt for the
update API.

Now, the problem is we try to be clever here and detect if disk
already has a source (indicated by <source/> subelement).
However, bare fact that the element is there does not mean disk
has source. Make our clever check better.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-25 15:57:23 +01:00
Jiri Denemark
0b50f4a025 Introduce migration iteration event
The VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION event will be triggered
whenever VIR_DOMAIN_JOB_MEMORY_ITERATION changes its value, i.e.,
whenever a new iteration over guest memory pages is started during
migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-01-21 16:36:08 +01:00
Michal Privoznik
3bd2ee5d55 virsh: Don't fetch status for all domains in cmdList
We are getting the list of domains and after that we iterate over
the list and try to get status for each domain hoping it will
skip over domains that disappeared meanwhile. However, this
solution to race is bogus - domain may disappear right after we
have checked its state and before we exec another API over it
(e.g. virDomainHasManagedSaveImage()). Also, when printing just
names or uuids (list --name / --uuid) we issue APIs to obtain the
values, however these require no RPC call as all requested info
is in virDomain object that client already has.
Therefore move the status obtaining only to the place that really
needs it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-21 08:13:34 +01:00
Michal Privoznik
f99f79e380 wireshark: Drop DESTDIR from install path
In 50078cfbcb I've tried to fix distcheck but accidentally
broke rpm build. The problem is that rpm build not only sets
DESTDIR but also passes plugindir path. This results in double
DESTDIR being in the plugin path, Drop one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-14 08:05:28 +01:00
Guido Günther
e8f771176e virsh: Update description of lxc-enter-namespace
Mention that we run a command in that namespace
2016-01-13 17:45:36 +01:00
Cole Robinson
e20dd2a4fd build: fix distdir with wireshark disabled
Even though the Makefile has WITH_WIRESHARK guards, the _SOURCES
variables are still processed when adding bits to the dist archive.

plugin.c is a generated file that is only built when wireshark is
enabled and it shouldn't be distributed, so use 'nodist'
2016-01-13 09:41:35 -05:00
Michal Privoznik
50078cfbcb wireshark: Install into DESTDIR
Like everything we install, it should be prefixed with DESTDIR.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-01-12 18:51:38 +01:00
Cole Robinson
3445acdbaa build: Kill tools/wireshark Makefiles
Just handle it all in tools/Makefile.am. I verified the generated output
looks similar to the pre patch output, but I didn't test it.
2016-01-12 11:30:08 -05:00
Andrea Bolognani
46c551fdb4 virsh: Fix alignment in VIRSH_COMMON_OPT_CONFIG definition 2016-01-12 09:18:24 +01:00