1. 15 3月, 2012 3 次提交
    • D
      Allow overriding default URI in config file · e457d5ef
      Daniel P. Berrange 提交于
      Currently if the URI passed to virConnectOpen* is NULL, then we
      
       - Look for LIBVIRT_DEFAULT_URI env var
       - Probe for drivers
      
      This changes it so that
      
       - Look for LIBVIRT_DEFAULT_URI env var
       - Look for 'uri_default' in $HOME/.libvirt/libvirt.conf
       - Probe for drivers
      e457d5ef
    • O
      virsh: A bit smarter attach-disk · 6227a220
      Osier Yang 提交于
      Detects the file type of source path if no "--sourcetype" and
      "driver" is specified, instead of always set the disk type as
      "block".
      6227a220
    • A
      virsh: fix invalid free · 68fd6a3b
      Alex Jia 提交于
      * tools/virsh.c (cmdDetachDisk): fix invalid free due to using
        uninitialised value.
      
      * How to reproduce?
      # virsh detach-disk a b
      error: failed to get domain 'a'
      *** glibc detected *** virsh: double free or corruption (out): 0x00007fff410ed1a0 ***
      ======= Backtrace: =========
      /lib64/libc.so.6[0x39cf0750c6]
      /usr/lib/libvirt.so.0(virFree+0x39)[0x7f045938a239]
      virsh[0x41c768]
      virsh[0x415075]
      virsh[0x425d64]
      /lib64/libc.so.6(__libc_start_main+0xfd)[0x39cf01ecdd]
      virsh[0x40a419]
      ======= Memory map: ========
      00400000-0044e000 r-xp 00000000 08:0e 760441                             /usr/bin/virsh
      0064e000-00650000 rw-p 0004e000 08:0e 760441                             /usr/bin/virsh
      ......
      39d7229000-39d722b000 r--p 00029000 08:0e 2183477                        /lib64/libk5crypto.so.3.1
      39d722b000-39d722c000 rw-p 0002b000 08:0e 2183477                        /lib64/lAborted (core dumped)
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      68fd6a3b
  2. 12 3月, 2012 1 次提交
    • E
      cpustats: report user and sys times · 759095f6
      Eric Blake 提交于
      Thanks to cgroups, providing user vs. system time of the overall
      guest is easy to add to our existing API.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_CPU_STATS_USERTIME)
      (VIR_DOMAIN_CPU_STATS_SYSTEMTIME): New constants.
      * src/util/virtypedparam.h (virTypedParameterArrayValidate)
      (virTypedParameterAssign): Enforce checking the result.
      * src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Fix offender.
      (qemuDomainGetTotalcpuStats): Implement new parameters.
      * tools/virsh.c (cmdCPUStats): Tweak output accordingly.
      759095f6
  3. 09 3月, 2012 1 次提交
    • O
      virsh: Use option alias for outmoded "--persistent" · 1e31b835
      Osier Yang 提交于
      Since VIR_DOMAIN_AFFECT_{LIVE,CONFIG,CURRENT} was created,
      all new virsh commands use "--config" to represents the
      persistent changing. This patch add "--config" option
      for the old commands which still use "--persistent",
      and "--persistent" is now alias of "--config".
      
      tools/virsh.c: (use "--config", and "--persistent" is
          alias of "--config" now).
          cmdDomIfSetLink, cmdDomIfGetLink, cmdAttachDevice,
          cmdDetachDevice, cmdUpdateDevice, cmdAttachInterface,
          cmdDetachInterface, cmdAttachDisk, cmdDetachDisk
      
      toos/virsh.pod: Update docs of the changed commands, and
          add some missed docs for "--config" (detach-interface,
          detach-disk, and detach-device).
      1e31b835
  4. 08 3月, 2012 5 次提交
    • E
      virsh: improve memory unit parsing · 210ed0e8
      Eric Blake 提交于
      The last vestige of the inaccurate 'kilobytes' when we meant 1024 is
      now gone.  And virsh is now useful for setting memory in units other
      than KiB.
      
      * tools/virsh.c (cmdSetmem, cmdSetmaxmem): Use new helper routine,
      allow passing bogus arguments on to hypervisor to test driver
      sanity checking, and fix leak on parse error.
      (vshMemtuneGetSize): New helper.
      (cmdMemtune): Use it.
      * tools/virsh.pod (setmem, setmaxmem, memtune): Document this.
      210ed0e8
    • E
      virsh: improve storage unit parsing · ab95da40
      Eric Blake 提交于
      Now can now do:
      
      virsh vol-resize $vol 10M
      virsh blockresize $dom $vol 10M
      
      to get both interfaces to resize to 10MiB.  The remaining wart
      is that vol-resize defaults to bytes, but blockresize defaults
      to KiB, but we can't break existing scripts; oh well, it's no
      worse than the same wart of the underlying virDomainBlockResize.
      
      The API for virStorageVolResize states that capacity must always
      be positive, and that the presence of shrink and delta flags is
      what implies a negative change.
      
      * tools/virsh.c (vshCommandOptScaledInt): New function.
      (cmdVolResize): Don't pass negative size.
      (cmdVolSize): Rename...
      (vshVolSize): ...and use new helper routine.
      (cmdBlockResize): Use new helper routine, and support new bytes
      flag.
      * tools/virsh.pod (NOTES): Document suffixes.
      (blockresize, vol-create-as, vol-resize): Point to notes.
      ab95da40
    • E
      virsh: add command aliases, and rename nodedev-detach · af3f9aab
      Eric Blake 提交于
      Just because our public API has a typo doesn't mean that virsh
      has to keep the typo.
      
      * tools/virsh.c (VSH_CMD_FLAG_ALIAS): New flag.
      (nodedevCmds): Use it.
      (cmdHelp): Omit alias commands.
      (cmdNodeDeviceDettach): Rename...
      (cmdNodeDeviceDetach): ...to this.
      * tools/virsh.pod (nodedev-detach): Document it.
      af3f9aab
    • E
      virsh: use option aliases · 3d150d32
      Eric Blake 提交于
      Command line interfaces should use dash, not underscore, as many
      keyboard layouts allow that to be typed with fewer shift key presses.
      
      Also, the US spelling of --tunneled gets more google hits than the
      UK spelling of --tunnelled.
      
      * tools/virsh.c (opts_migrate): Allow US variant.
      (opts_blkdeviotune): Prefer - over _.
      * tools/virsh.pod (blkdeviotune): Fix spelling.
      3d150d32
    • E
      virsh: add option aliases · 1c56b9fe
      Eric Blake 提交于
      In the past, we have created some virsh options with less-than-stellar
      names.  For back-compat reasons, those names must continue to parse,
      but we don't want to document them in help output.  This introduces
      a new option type, an alias, which points to a canonical option name
      later in the option list.
      
      I'm actually quite impressed that our code has already been factored
      to do all option parsing through common entry points, such that I
      got this added in relatively few lines of code!
      
      * tools/virsh.c (VSH_OT_ALIAS): New option type.
      (opts_echo): Hook up an alias, for easy testing.
      (vshCmddefOptParse, vshCmddefHelp, vshCmddefGetOption): Allow for
      aliases.
      * tools/virsh.pod (NOTES): Document promise of back-compat.
      * tests/virshtest.c (mymain): Test new feature.
      1c56b9fe
  5. 07 3月, 2012 1 次提交
  6. 05 3月, 2012 1 次提交
    • P
      libvirt-guests: Add parallel startup and shutdown of guests · 6c3642e9
      Peter Krempa 提交于
      With this patch, it's possible to shut down guests in parallel. Parallel
      startup was possible before, but this functionality was not documented
      properly.
      
      To enable parallel startup set the START_DELAY to 0.
      
      Parallel shutdown has a configurable parameter PARALLEL_SHUTDOWN that
      defines the number of machines being shut down in parallel. Enabling
      this feature changes the semantics of SHUTDOWN_TIMEOUT parameter that is
      applied as a cumulative timeout to shutdown all guests on a URI.
      6c3642e9
  7. 02 3月, 2012 1 次提交
    • E
      build: use correct type for pid and similar types · 3e2c3d8f
      Eric Blake 提交于
      No thanks to 64-bit windows, with 64-bit pid_t, we have to avoid
      constructs like 'int pid'.  Our API in libvirt-qemu cannot be
      changed without breaking ABI; but then again, libvirt-qemu can
      only be used on systems that support UNIX sockets, which rules
      out Windows (even if qemu could be compiled there) - so for all
      points on the call chain that interact with this API decision,
      we require a different variable name to make it clear that we
      audited the use for safety.
      
      Adding a syntax-check rule only solves half the battle; anywhere
      that uses printf on a pid_t still needs to be converted, but that
      will be a separate patch.
      
      * cfg.mk (sc_correct_id_types): New syntax check.
      * src/libvirt-qemu.c (virDomainQemuAttach): Document why we didn't
      use pid_t for pid, and validate for overflow.
      * include/libvirt/libvirt-qemu.h (virDomainQemuAttach): Tweak name
      for syntax check.
      * src/vmware/vmware_conf.c (vmwareExtractPid): Likewise.
      * src/driver.h (virDrvDomainQemuAttach): Likewise.
      * tools/virsh.c (cmdQemuAttach): Likewise.
      * src/remote/qemu_protocol.x (qemu_domain_attach_args): Likewise.
      * src/qemu_protocol-structs (qemu_domain_attach_args): Likewise.
      * src/util/cgroup.c (virCgroupPidCode, virCgroupKillInternal):
      Likewise.
      * src/qemu/qemu_command.c(qemuParseProcFileStrings): Likewise.
      (qemuParseCommandLinePid): Use pid_t for pid.
      * daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
      * src/conf/domain_conf.h (_virDomainObj): Likewise.
      * src/probes.d (rpc_socket_new): Likewise.
      * src/qemu/qemu_command.h (qemuParseCommandLinePid): Likewise.
      * src/qemu/qemu_driver.c (qemudGetProcessInfo, qemuDomainAttach):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessAttach): Likewise.
      * src/qemu/qemu_process.h (qemuProcessAttach): Likewise.
      * src/uml/uml_driver.c (umlGetProcessInfo): Likewise.
      * src/util/virnetdev.h (virNetDevSetNamespace): Likewise.
      * src/util/virnetdev.c (virNetDevSetNamespace): Likewise.
      * tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
      * src/conf/storage_conf.h (_virStoragePerms): Use mode_t, uid_t,
      and gid_t rather than int.
      * src/security/security_dac.c (virSecurityDACSetOwnership): Likewise.
      * src/conf/storage_conf.c (virStorageDefParsePerms): Avoid
      compiler warning.
      3e2c3d8f
  8. 01 3月, 2012 1 次提交
    • E
      virsh: expose partial pull · ff4c25ba
      Eric Blake 提交于
      Now virsh can call virDomainBlockRebase.
      
      * tools/virsh.c (cmdBlockPull): Add --base parameter.
      (blockJobImpl): Use it to expose BlockRebase API.
      * tools/virsh.pod (blockpull): Document it.
      ff4c25ba
  9. 29 2月, 2012 4 次提交
  10. 28 2月, 2012 4 次提交
  11. 27 2月, 2012 2 次提交
    • P
      virsh: add support for VIR_DOMAIN_CONSOLE_* flags · afa4336e
      Peter Krempa 提交于
      This patch adds support for the newly introduced
      VIR_DOMAIN_CONSOLE_FORCE and VIR_DOMAIN_CONSOLE_SAFE flags. The console
      command now has an optional parameter --force that specifies that the
      user wants to forcibly interrupt an ongoing console session and create
      a new one. Flag --safe requests that the console should be opened only
      if the hypervisor driver supports safe console handling.
      
      The behaviour to this point was that the daemon opened two streams to
      the console, that competed for data from the pipe, and the result was
      that both of the consoles ended up scrambled.
      
      This patch doesn't modify operation of other commands dealing with
      console connections (start, create) as those open connections to newly
      started domains making it virtually impossible for another client to race
      for the console and steal it.
      
      * tools/console.c:
              - add support for flag passthrough
      * tools/console.h:
              - modify function prototypes to match impl.
      * tools/virsh.c:
              - add flag --force for the console command
      afa4336e
    • M
      virsh: Expose virDomainPMWakeup · a04d10f7
      Michal Privoznik 提交于
      a04d10f7
  12. 25 2月, 2012 2 次提交
    • L
      virsh: fix informational message in iface-bridge command · 4a923600
      Laine Stump 提交于
      See: https://bugzilla.redhat.com/show_bug.cgi?id=797066
      
      The position of the bridge name and ethernet device name were
      accidentally swapped in the message informing of success creating the
      bridge.
      4a923600
    • D
      Improve error reporting when virsh console is run without a TTY · af6b61ba
      Daniel P. Berrange 提交于
      If attempting to run
      
        ssh root@somehost virsh console someguest
      
      You'll get an error
      
        2012-02-15 13:11:47.683+0000: 4765: info : libvirt version: 0.9.10, package: 1.fc18 (Unknown, 2012-02-15-11:48:57, lettuce.camlab.fab.redhat.com)
        2012-02-15 13:11:47.683+0000: 4765: error : vshRunConsole:320 : unable to get tty attributes: Invalid argument
        Connected to domain f16x86_64
        Escape character is ^]
      
      There are several problems here
      
       - The actual error message is bad for users
       - We shouldn't rely on VIR_ERROR for this case
       - The prompt makes it look like we still connected
         because we didn't flush stdout.
      
      * virsh.c: Flush stdout before starting console and check
        for a valid tty
      af6b61ba
  13. 23 2月, 2012 1 次提交
  14. 22 2月, 2012 1 次提交
    • P
      virsh: Enhance list command to ease creation of shell scripts · 419e5fb3
      Peter Krempa 提交于
      This patch adds new options to the "virsh list" command enabling
      filtering of persistent and transient domains along with the option to
      print only UUIDs or names of domains instead of printing the table.
      
      Option --name prints domain names (one per line) instead of the default
      table. Similarly --uuid prints domain's UUID. The option --table is
      an alias for the default behavior.
      
      Aditionally --persistent and/or --transient may be specified to filter
      the output of domains.
      419e5fb3
  15. 21 2月, 2012 1 次提交
    • P
      virsh: Fix docs for list command · c4c68b00
      Peter Krempa 提交于
      Commit fad5cd21 introduced option to
      display domain's title in the list command output. There was a mistake
      in the virsh man page example for this command stating --note instead of
      --title.
      c4c68b00
  16. 14 2月, 2012 1 次提交
    • E
      qemu: make block io tuning smarter · 172d3429
      Eric Blake 提交于
      When blkdeviotune was first committed in 0.9.8, we had the limitation
      that setting one value reset all others.  But bytes and iops should
      be relatively independent.  Furthermore, setting tuning values on
      a live domain followed by dumpxml did not output the new settings.
      
      * src/qemu/qemu_driver.c (qemuDiskPathToAlias): Add parameter, and
      update callers.
      (qemuDomainSetBlockIoTune): Don't lose previous unrelated
      settings.  Make live changes reflect to dumpxml output.
      * tools/virsh.pod (blkdeviotune): Update documentation.
      172d3429
  17. 13 2月, 2012 1 次提交
  18. 08 2月, 2012 3 次提交
  19. 06 2月, 2012 2 次提交
    • P
      virsh: Fix resource leak while listing inactive domains with titles · 35d31954
      Peter Krempa 提交于
      Commit fad5cd21 introduces a new flag
      that allows to show domain's title with domains. This commit introduced
      resource leak while listing inactive domains with titles.
      35d31954
    • A
      virsh: Avoid invalid read of size errors · f228917a
      Alex Jia 提交于
      Detected by valgrind. the codes are allocating 0 bytes memory to variable
      cpumap by vshCalloc function, and then the function VIR_USE_CPU will access
      it later, a invalid read error will be hit.
      
      * tools/virsh.c(cmdVcpuPin): fix invalid read error.
      
      * How to reproduce?
      % valgrind -v --read-var-info=yes virsh vcpupin <domain> 0 0
      
      * Actual result:
      
      ==27271== ERROR SUMMARY: 5 errors from 2 contexts (suppressed: 8 from 6)
      ==27271==
      ==27271== 1 errors in context 1 of 2:
      ==27271== Invalid read of size 1
      ==27271==    at 0x39CF087E2E: __GI_memcpy (in /lib64/libc-2.12.so)
      ==27271==    by 0x39CF114FDC: xdrmem_putbytes (in /lib64/libc-2.12.so)
      ==27271==    by 0x39CF114707: xdr_opaque (in /lib64/libc-2.12.so)
      ==27271==    by 0x4D56194: xdr_remote_domain_pin_vcpu_args (remote_protocol.c:1844)
      ==27271==    by 0x4D6CCE1: virNetMessageEncodePayload (virnetmessage.c:341)
      ==27271==    by 0x4D5A44B: virNetClientProgramCall (virnetclientprogram.c:327)
      ==27271==    by 0x4D36EDB: callWithFD (remote_driver.c:4546)
      ==27271==    by 0x4D36F7B: call (remote_driver.c:4567)
      ==27271==    by 0x4D3B2C1: remoteDomainPinVcpu (remote_client_bodies.h:1566)
      ==27271==    by 0x4D199D3: virDomainPinVcpu (libvirt.c:8585)
      ==27271==    by 0x4241F4: cmdVcpuPin (virsh.c:5262)
      ==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
      ==27271==  Address 0x5602b80 is 0 bytes after a block of size 0 alloc'd
      ==27271==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
      ==27271==    by 0x4C89BDF: virAllocN (memory.c:129)
      ==27271==    by 0x423868: _vshCalloc.clone.2 (virsh.c:454)
      ==27271==    by 0x423EF9: cmdVcpuPin (virsh.c:5190)
      ==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
      ==27271==    by 0x426583: main (virsh.c:19289)
      ==27271==
      ==27271==
      ==27271== 4 errors in context 2 of 2:
      ==27271== Invalid read of size 1
      ==27271==    at 0x424133: cmdVcpuPin (virsh.c:5245)
      ==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
      ==27271==    by 0x426583: main (virsh.c:19289)
      ==27271==  Address 0x5602b80 is 0 bytes after a block of size 0 alloc'd
      ==27271==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
      ==27271==    by 0x4C89BDF: virAllocN (memory.c:129)
      ==27271==    by 0x423868: _vshCalloc.clone.2 (virsh.c:454)
      ==27271==    by 0x423EF9: cmdVcpuPin (virsh.c:5190)
      ==27271==    by 0x4150A6: vshCommandRun (virsh.c:17712)
      ==27271==    by 0x426583: main (virsh.c:19289)
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      f228917a
  20. 04 2月, 2012 4 次提交
    • E
      maint: consolidate several .gitignore files · 8f00276c
      Eric Blake 提交于
      Unlike .cvsignore under CVS, git allows for ignoring nested
      names.  We weren't very consistent where new tests were
      being ignored (some in .gitignore, some in tests/.gitignore),
      and I found it easier to just consolidate everything.
      
      * .gitignore: Subsume entries from subdirectories.
      * daemon/.gitignore: Delete.
      * docs/.gitignore: Likewise.
      * docs/devhelp/.gitignore: Likewise.
      * docs/html/.gitignore: Likewise.
      * examples/dominfo/.gitignore: Likewise.
      * examples/domsuspend/.gitignore: Likewise.
      * examples/hellolibvirt/.gitignore: Likewise.
      * examples/openauth/.gitignore: Likewise.
      * examples/domain-events/events-c/.gitignore: Likewise.
      * include/libvirt/.gitignore: Likewise.
      * src/.gitignore: Likewise.
      * src/esx/.gitignore: Likewise.
      * tests/.gitignore: Likewise.
      * tools/.gitignore: Likewise.
      8f00276c
    • L
      virsh: add --graceful switch to destroy command · 3e952ecc
      Laine Stump 提交于
      This allows virsh to use the new VIR_DOMAIN_DESTROY_GRACEUL flag for
      virDomainDestroyFlags.
      3e952ecc
    • E
      build: prohibit raw malloc and free · a7cfd709
      Eric Blake 提交于
      Our HACKING discourages use of malloc and free, for at least
      a couple of years now.  But we weren't enforcing it, until now :)
      
      For now, I've exempted python and tests, and will clean those up
      in subsequent patches.  Examples should be permanently exempt,
      since anyone copying our examples won't have use of our
      internal-only memory.h via libvirt_util.la.
      
      * cfg.mk (sc_prohibit_raw_allocation): New rule.
      (exclude_file_name_regexp--sc_prohibit_raw_allocation): and
      exemptions.
      * src/cpu/cpu.c (cpuDataFree): Avoid false positive.
      * src/conf/network_conf.c (virNetworkDNSSrvDefParseXML): Fix
      offenders.
      * src/libxl/libxl_conf.c (libxlMakeDomBuildInfo, libxlMakeVfb)
      (libxlMakeDeviceModelInfo): Likewise.
      * src/rpc/virnetmessage.c (virNetMessageSaveError): Likewise.
      * tools/virsh.c (_vshMalloc, _vshCalloc): Likewise.
      a7cfd709
    • E
      build: clean up CPPFLAGS/INCLUDES usage · cb33ee1f
      Eric Blake 提交于
      Our syntax checker missed all-lower-case variables (this will
      be fixed by the next .gnulib update).  Additionally, anywhere
      that we mix in-tree files with generated files, automake recommends
      listing builddir prior to srcdir for VPATH builds.
      
      * src/Makefile.am (*_la_CFLAGS): Favor $(top_srcdir).
      (INCLUDES): Likewise, and follow automake recommendations on
      builddir before srcdir.
      * python/Makefile.am (INCLUDES): Swap directory order.
      * tests/Makefile.am (INCLUDES): Likewise.
      * tools/Makefile.am (INCLUDES): Likewise.
      * daemon/Makefile.am (INCLUDES): Likewise.
      (libvirtd.init, libvirtd.service): Favor $().
      * examples/hellolibvirt/Makefile.am (hellolibvirt_LDADD):
      Likewise.
      * examples/openauth/Makefile.am (openauth_LDADD): Likewise.
      * examples/dominfo/Makefile.am (INCLUDES): Drop dead include.
      * examples/domsuspend/Makefile.am (INCLUDES): Likewise.
      cb33ee1f