Commit Graph

925 Commits

Author SHA1 Message Date
Daniel P. Berrange
e4e69e899e Apply security label when entering LXC namespaces
Add a new virDomainLxcEnterSecurityLabel() function as a
counterpart to virDomainLxcEnterNamespaces(), which can
change the current calling process to have a new security
context. This call runs client side, not in libvirtd
so we can't use the security driver infrastructure.

When entering a namespace, the process spawned from virsh
will default to running with the security label of virsh.
The actual desired behaviour is to run with the security
label of the container most of the time. So this changes
virsh lxc-enter-namespace command to invoke the
virDomainLxcEnterSecurityLabel method.

The current behaviour is:

LABEL                             PID TTY          TIME CMD
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 1 pts/0 00:00:00 systemd
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 3 pts/1 00:00:00 sh
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 24 ? 00:00:00 systemd-journal
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 29 ? 00:00:00 dhclient
staff_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 47 ? 00:00:00 ps

Note the ps command is running as unconfined_t,  After this patch,

The new behaviour is this:

virsh -c lxc:/// lxc-enter-namespace dan -- /bin/ps -eZ
LABEL                             PID TTY          TIME CMD
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 1 pts/0 00:00:00 systemd
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 3 pts/1 00:00:00 sh
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 24 ? 00:00:00 systemd-journal
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 32 ? 00:00:00 dhclient
system_u:system_r:svirt_lxc_net_t:s0:c0.c1023 38 ? 00:00:00 ps

The '--noseclabel' flag can be used to skip security labelling.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-03-13 15:16:37 +00:00
Ján Tomko
2fc5ff11ab virsh: fix snapshot-create with no xmlfile
Properly check the return value of vshCommandOptStringReq for xmlfile:
* error out on incorrect input (--xmlfile '')
* use default XML <domainsnapshot/> with no --xmlfile specified

(Broken by commit b2e8585)

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=919826
2013-03-11 13:39:11 +01:00
Peter Krempa
38cc07b7bc virsh-domain: Remove unused vshCompleteXMLFromDomain
The function is marked as unused and breaks compilation on RHEL4. Remove
it from the tree until a new use case can be found.
2013-03-10 10:18:23 +01:00
Peter Krempa
406dc47757 Revert "Ensure xmlSaveToBuffer is always defined"
The commit originally fixed code that isn't being used. Revert
it and remove the unused code as a real fix.

This reverts commit a66b32d929.
2013-03-10 10:18:23 +01:00
Daniel P. Berrange
a66b32d929 Ensure xmlSaveToBuffer is always defined
RHEL4 vintage libxml2 header files are missing xmlSaveToBuffer
despite the symbol existing in the binary

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-03-07 18:10:35 +00:00
Peter Krempa
0d00c7a3bd virsh-snapshot: Add ability to print only snapshot names
Help script creators by not having to parse the names from the table.
2013-03-05 08:34:48 +01:00
Jiri Denemark
e94aeb1428 virsh: Add migrate-compcache command
This is a command wrapping virDomainMigrateGetCompressionCache and
virDomainMigrateSetCompressionCache.
2013-02-22 17:35:59 +01:00
Jiri Denemark
38ab12251e virsh: Use virDomainGetJobStats in domjobinfo if available 2013-02-22 17:35:58 +01:00
Jiri Denemark
ecfff1dab3 Introduce VIR_MIGRATE_COMPRESSED flag
This flag may be used with migration APIs to request compression of
migration data.
2013-02-22 17:35:58 +01:00
Guannan Ren
dd71fa110a virsh: distinguish errors between missing argument and wrong option
Specifying ':' to suppress the error messages printed by getopt().
Then, distinguish the two types of errors.

Before:
 # virsh -c
   virsh: option requires an argument -- 'c'
   error: unsupported option '-?'. See --help.

After:
 # virsh -c
   error: option '-c' requires an argument

 # virsh -x
   error: unsupported option '-x'. See --help.
2013-02-20 10:14:25 +08:00
Jiri Denemark
ada9e157a2 virsh: Always print capacity unit
It doesn't make sense to print the unit (B) only with Ki, Mi, ...
prefixes. Even those poor bytes under 1 KiB are still bytes :-)
2013-02-19 10:52:37 +01:00
John Ferlan
1d816219eb virsh: Resolve possible NULL dereference
Coverity found that commit '41b5e845' had a possible NULL dereference on
arg->data processing
2013-02-16 07:44:35 -05:00
Michal Privoznik
bbd09adbe2 virsh-volume.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
53b574812b virsh-snapshot.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
44ac20b85b virsh-secret.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
d84608120c virsh-pool.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
5986665f55 virsh-nwfilter.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
f036f38686 virsh-nodedev.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
a8236b0656 virsh-network.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:22 +01:00
Michal Privoznik
bcd660a472 virsh-interface.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:21 +01:00
Michal Privoznik
f3ce4ec661 virsh-host.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:21 +01:00
Michal Privoznik
38d52f6318 virsh-domain.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:21 +01:00
Michal Privoznik
2e78351916 virsh-domain-monitor.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:21 +01:00
Michal Privoznik
6792676a04 virsh.c: Switch to c99 initialization of vshCmdInfo 2013-02-12 17:50:21 +01:00
Michal Privoznik
df5fd11f86 virsh: Switch to c99 initialization of vshCmdDef 2013-02-12 17:50:21 +01:00
Osier Yang
9be2018469 virsh: Use virNodeDeviceLookupSCSIHostByWWN
Only nodedev-destroy and nodedev-dumpxml can benifit from the
new API, other commands like nodedev-detach only works for
PCI devices, WWN makes no sense for them.
2013-02-12 00:23:57 +08:00
Peter Krempa
fe69656ea9 virsh-snapshot: Reject --no-metadata together with --print-xml
Manual for "virsh snapshot-create-as" states that --no-metadata and
--print-xml are incompatible. Honor this detail in the code.
2013-02-11 14:50:20 +01:00
Peter Krempa
02b0d3f3ac virsh-snapshot: Refactor some details in virsh snapshot-create-as
This patch simplifies the creation of XML, some error paths and adds
correct approach to check for virBuffer errors.
2013-02-11 14:50:20 +01:00
Peter Krempa
e06816289c virsh-snapshot: Fix XPath query to determine snapshot state
The query didn't match the external state correctly for offline internal
snapshots.
2013-02-08 15:38:22 +01:00
Michal Privoznik
0d36f228a4 virCondDestroy: Lose attribute RETURN_CHECK
We are wrapping it in ignore_value() anyway.
2013-02-08 09:12:11 +01:00
Peter Krempa
fbe2d4940d virsh-secret: Refactor error paths
This patch switches string option retrieval to vshCommandOptStringReq
and refactors some error paths to avoid an unlikely memory leak of a
secret object in cmdSecretSetValue.
2013-02-04 14:17:45 +01:00
Peter Krempa
05af594bf7 virsh-nwfilter: Update nwfilter commands to use vshCommandOptStringReq 2013-02-04 14:17:45 +01:00
Peter Krempa
b2e8585555 virsh-snapshot: Update snapshot commands to use vshCommandOptStringReq
also avoids potential NULL pointer dereference:

$ virsh snapshot-current asdf ""
error: invalid snapshotname argument '(null)'

by removing the error message in favor of vshCommandOptStringReq
2013-02-04 14:17:45 +01:00
Peter Krempa
351f7a2f2c virsh-snapshot: Refactor cmdSnapshotDumpXML
This patch simplifies error paths and switches to use
vshCommandOptStringReq for argument retrieval in cmdSnapshotDumpXML
2013-02-04 14:17:44 +01:00
Peter Krempa
e9dc07393a virsh-nodedev: Refactor error paths, error messages and whitespace
This patch adds some empty lines to separate blocks of code, cleans up
unnecessary error message constructs in cmdNodeDeviceDetach,
cmdNodeDeviceReAttach, cmdNodeDeviceReset and refactors error paths in
cmdNodeDeviceDumpXML.
2013-02-04 14:17:44 +01:00
Peter Krempa
7c5c51d174 virsh-nodedev: Update node device commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
56dc64cfdd virsh-interface: Update interface commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
4e31e733e4 virsh-network: Update network commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
edbdc45b6d virsh-host: Update host commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
fa956d9055 virsh-domain: Update domain commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
f605be8235 virsh-domain-monitor: Update domain commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
1daa4ba33a virsh-volume: Update volume commands to use vshCommandOptStringReq 2013-02-04 14:17:44 +01:00
Peter Krempa
98007c8138 virsh-pool: Update pool commands to use vshCommandOptStringReq
Rework most of option string retrievals to the new helper.
2013-02-04 14:17:43 +01:00
Peter Krempa
41b5e8451b virsh: Add helper to request string arguments with error reporting
This patch adds a helper function with similar semantics to
vshCommandOptString that requests a string argument, but does some error
reporting without the need to do it in the functions themselves.

The error reporting also provides information about the parameter whose
retrieval failed.
2013-02-04 14:17:39 +01:00
Peter Krempa
d1de0c3d1a virsh-pool: Rename helper function buildPoolXML to vshBuildPoolXML 2013-02-04 10:56:27 +01:00
Peter Krempa
042bf709a9 virsh-volume: Rename helper function makeCloneXML to vshMakeCloneXML 2013-02-04 10:34:33 +01:00
Peter Krempa
f4464002fc virsh-snapshot: Fix coding style and remove dead code
buffer won't be NULL in any case when reaching the check and the first
block of the if statement was lacking parentheses
2013-02-04 10:34:33 +01:00
John Ferlan
46b1d8cf7a Enforce return check on virAsprintf() calls
Way back when I started making changes for Coverity messages my first set
were to a bunch of CHECKED_RETURN errors.  In particular virAsprintf() had
a few callers that Coverity noted didn't check their return (although some
did check if the buffer being printed to was NULL or not).

It was suggested at the time as a further patch an ATTRIBUTE_RETURN_CHECK
should be added to virAsprintf(), see:

https://www.redhat.com/archives/libvir-list/2013-January/msg00120.html

This patch does that and fixes a few more instances not found by Coverity
that failed the check.
2013-01-30 14:42:22 -07:00
Peter Krempa
366a3d52ee snapshot: Mention disk-only snapshots in error message
When a disk-only snapshot is requested the domain is treated as if it
was offline. This forbids to mix memory checkpoints with the DISK_ONLY
flag.

This patch improves the error message and mentions the restriction in
the virsh man page.
2013-01-30 11:08:41 +01:00
Jiri Denemark
b8a32e0e94 build: Regenerate man pages on version bump
Whenever libvirt version changes in configure.ac, we need to regenerate
man pages so that they contain correct version info.
2013-01-29 13:23:19 +01:00