1. 07 8月, 2019 4 次提交
    • D
      tools: split virt-login-shell into two binaries · 4feeb2d9
      Daniel P. Berrangé 提交于
      The virt-login-shell binary is a setuid program that takes
      no arguments. When invoked it looks at the invoking uid,
      resolves it to a username, and finds an LXC guest with the
      same name. It then starts the guest and runs the shell in
      side the namespaces of the container.
      
      Given this set of tasks the virt-login-shell binary needs
      to connect to libvirtd, make various other libvirt API calls.
      This is a problem for setuid binaries as various libraries
      that libvirt.so links to are not safe. For example, they have
      constructor functions which execute an unknown amount of code
      that can be influenced by env variables.
      
      For this reason virt-login-shell doesn't use libvirt.so,
      but instead links to a custom, cut down, set of source files
      sufficient to be a local client only.
      
      This introduces a problem for integrating glib2 into libvirt
      though, as once integrated, there would be no way to build
      virt-login-shell without an external dependancy on glib2 and
      this is definitely not setuid safe.
      
      To resolve this problem, we split the virt-login-shell binary
      into two parts. The first part is setuid and does almost
      nothing. It simply records the original uid+gid, and then
      invokes the virt-login-shell-helper binary. Crucially when
      it does this it completes scrubs all environment variables.
      It is thus safe for virt-login-shell-helper to link to the
      normal libvirt.so. Any things that constructor functions
      do cannot be influenced by user control env vars or cli
      args.
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      4feeb2d9
    • D
      tools: rename source for virt-login-shell · 46754ffb
      Daniel P. Berrangé 提交于
      We'll shortly be renaming the binary to virt-login-shell-helper
      and introducing a new tool as virt-login-shell. Renaming the
      source file first gives a much more usefull diff for the next
      commit.
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      46754ffb
    • D
      tools: fix double error reporting in virt-login-shell · cd1f25a9
      Daniel P. Berrangé 提交于
      The public API entry points will call virDispatchError which
      will print to stderr by default. We then jump to a cleanup
      path which calls virDispatchError again.
      
      We tried to stop the entry points printing to stderr, but
      incorrectly called virSetErrorFunc. It needs a real function
      that is a no-op, not a NULL function.
      
      Once we fix virSetErrorFunc, then we need to use fprintf in
      the cleanup path instead of virDispatchError.
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      cd1f25a9
    • D
      tools: fix crash in virt-login-shell if config doesn't exist · 275bcbeb
      Daniel P. Berrangé 提交于
      If the 'allowed_users' config setting in virt-login-shell.conf
      does not exist, we dereference a NULL pointer resulting in a
      crash. We should check for this case and thus ensure the user
      is denied access gracefully.
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      275bcbeb
  2. 06 8月, 2019 2 次提交
    • M
      lib: Format PCI address differently · 9b332820
      Michal Privoznik 提交于
      Currently, the way we format PCI address is using printf-s
      precision, e.g. "%.4x". This works if we don't want to print any
      value outside of bounds (which is usually the case). However,
      turns out, PCI domain can be 0x10000 which doesn't work well with
      our format strings. However, if we change the format string to
      "%04x" then we still pad small values with zeroes but also we are
      able to print values that are larger than four digits. In fact,
      this format string used by kernel to print a PCI address:
      
        "%04x:%02x:%02x.%d"
      
      The other three format strings (for bus, device and function) are
      changed too, so that we use the same format string as kernel.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      9b332820
    • R
      tools: console: Use proper constructor · 9fbf5685
      Roman Bolshakov 提交于
      "virsh console" on macOS cannot attach to a domain and it doesn't matter if
      it's local or remote domain:
        $ ~ virsh console vm
        Connected to domain vm
        Escape character is ^]
        error: internal error: unable to wait on console condition
      
      The error comes from pthread_cond_wait that fails with EINVAL. The mutex
      in the parent is not initialized with pthread_mutex_init and it results
      in silent failure of pthead_mutex_lock and the attach failure.
      
      Fixes: 98361cc3 ("tools: console: make console virLockableObject")
      Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      9fbf5685
  3. 29 7月, 2019 1 次提交
  4. 27 7月, 2019 1 次提交
    • E
      backup: Implement virsh support for checkpoints · 689beaa4
      Eric Blake 提交于
      Introduce a bunch of new virsh commands for managing checkpoints in
      isolation. More commands are needed for performing incremental
      backups, but these commands were easy to implement by modeling heavily
      after virsh-snapshot.c. There is no need for checkpoint-revert or
      checkpoint-current since those snapshot APIs have no checkpoint
      counterpart.  Similarly, it is not necessary to change which
      checkpoint is current when redefining from XML, since until we
      integrate checkpoints with snapshots, there is only a linear chain
      (and you can deduce the current checkpoint by instead using
      'checkpoint-list --leaves').  Other aspects of checkpoint-list are
      also a bit simpler than the snapshot counterpart, in part because we
      don't have to cater to back-compat to older API.
      
      Upcoming patches will test these interfaces once the test driver
      supports checkpoints.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      689beaa4
  5. 25 7月, 2019 1 次提交
  6. 19 7月, 2019 1 次提交
    • J
      virsh migrate: Properly check for --parallel-connections · 88ce7bac
      Jiri Denemark 提交于
      Ever since --parallel-connections option for virsh migrate was
      introduced we did not properly check the return value of
      vshCommandOptInt. We would set VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS
      parameter even if vshCommandOptInt returned 0 (which means
      --parallel-connections was not specified) when another int option which
      was checked earlier was specified with a nonzero value.
      
      Specifically, running virsh migrate with either
      --auto-converge-increment, --auto-converge-initial, --comp-mt-dthreads,
      --comp-mt-threads, or --comp-mt-level would set
      VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS parameter and if --parallel
      option was not used, libvirt would complain
      
          error: invalid argument: Turn parallel migration on to tune it
      
      even though --parallel-connections option was not used at all.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1726643Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
      88ce7bac
  7. 18 7月, 2019 2 次提交
  8. 15 7月, 2019 5 次提交
  9. 13 7月, 2019 2 次提交
  10. 11 7月, 2019 1 次提交
    • E
      snapshot: Add VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE flag · 95f8e323
      Eric Blake 提交于
      We've been doing a terrible job of performing XML validation in our
      various API that parse XML with a corresponding schema (we started
      with domains back in commit dd69a14f, v1.2.12, but didn't catch all
      domain-related APIs, didn't document the use of the flag, and didn't
      cover other XML). New APIs (like checkpoints) should do the validation
      unconditionally, but it doesn't hurt to continue retrofitting existing
      APIs to at least allow the option.
      
      While there are many APIs that could be improved, this patch focuses
      on wiring up a new snapshot XML creation flag through all the
      hypervisors that support snapshots, as well as exposing it in 'virsh
      snapshot-create'.  For 'virsh snapshot-create-as', we blindly set the
      flag without a command-line option, since the XML we create from the
      command line should generally always comply (note that validation
      might cause failures where it used to succeed, such as if we tighten
      the RNG to reject a name of '../\n'); but blindly passing the flag
      means we also have to add in fallback code to disable validation if
      the server is too old to understand the flag.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Acked-by: NPeter Krempa <pkrempa@redhat.com>
      95f8e323
  11. 09 7月, 2019 1 次提交
    • L
      virsh: support block device storage type in virshParseSnapshotDiskspec · 7ca81e6f
      Liu Dayu 提交于
      virsh snapshot-create-as supports 'file' storage type in --diskspec by default.
      But it doesn't support 'block' storage type in the virshParseSnapshotDiskspec().
      So if a snapshot on a block device (e.g. LV) was created, the type of
      current running storage source in dumpxml is inconsistent with the actual
      backend storage source. It will check file-system type mismatch failed
      and return an error message of 'Migration without shared storage is unsafe'
      when VM performs a live migration after this snapshot.
      
      Considering virsh has to be able to work remotely that recognizing a block device
      by prefix /dev/ or by stat() may be not suitable, so adding a "stype" field
      for the --diskspec string which will be either "file" or "block".
      e.g. --diskspec vda,snapshot=external,driver=qcow2,stype=block,file=/dev/xxx.
      Signed-off-by: NLiu Dayu <liu.dayu@zte.com.cn>
      Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
      7ca81e6f
  12. 03 7月, 2019 1 次提交
  13. 01 7月, 2019 1 次提交
  14. 20 6月, 2019 1 次提交
  15. 19 6月, 2019 1 次提交
  16. 17 6月, 2019 1 次提交
  17. 10 6月, 2019 1 次提交
  18. 06 6月, 2019 3 次提交
  19. 20 5月, 2019 1 次提交
    • H
      qemu: Add entry for balloon stats stat-htlb-pgalloc and stat-htlb-pgfail · a699b19f
      Han Han 提交于
      Qemu added reporting of virtio balloon new statistics stat-htlb-pgalloc and
      stat-htlb-pgfail since qemu-3.0 commit b7b12644297. The value of
      stat-htlb-pgalloc represents the number of successful hugetlb page allocations
      while stat-htlb-pgfail represents the number of failed ones. Add this
      statistics reporting to libvirt.
      
      To enable this feature for vm, guest kenel >= 4.17 is required because
      the exporting hugetlb page allocation for virtio balloon is introduced
      since 6c64fe7f.
      Signed-off-by: NHan Han <hhan@redhat.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      a699b19f
  20. 13 5月, 2019 1 次提交
    • M
      virsh: Don't leak disk targets in cmdDomBlkError · d55be922
      Michal Privoznik 提交于
      The virDomainGetDiskErrors() API copies disk targets into @disks
      array that we allocate. But we forgot to free it:
      
      ==140828== 16 bytes in 4 blocks are definitely lost in loss record 41 of 242
      ==140828==    at 0x4C2F08F: malloc (vg_replace_malloc.c:299)
      ==140828==    by 0x8C406D9: strdup (in /lib64/libc-2.28.so)
      ==140828==    by 0x5377DD3: virStrdup (virstring.c:966)
      ==140828==    by 0x54C112F: testDomainGetDiskErrors (test_driver.c:3068)
      ==140828==    by 0x55C863D: virDomainGetDiskErrors (libvirt-domain.c:10988)
      ==140828==    by 0x15D1FA: cmdDomBlkError (virsh-domain-monitor.c:1215)
      ==140828==    by 0x17F1A8: vshCommandRun (vsh.c:1335)
      ==140828==    by 0x13489E: main (virsh.c:920)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      d55be922
  21. 30 4月, 2019 1 次提交
  22. 26 4月, 2019 1 次提交
  23. 16 4月, 2019 1 次提交
  24. 15 4月, 2019 2 次提交
  25. 12 4月, 2019 2 次提交
  26. 11 4月, 2019 1 次提交