1. 15 8月, 2011 1 次提交
    • J
      qemu: Refactor do{Tunnel,Native}Migrate functions · 52e2918a
      Jiri Denemark 提交于
      The core of these two functions is very similar and most of it is even
      exactly the same. Factor out the core functionality into a separate
      function to remove code duplication and make further changes easier.
      52e2918a
  2. 13 8月, 2011 1 次提交
    • D
      Move pidfile functions into util/virpidfile.{c,h} · f80a4ed7
      Daniel P. Berrange 提交于
      The functions for manipulating pidfiles are in util/util.{c,h}.
      We will shortly be adding some further pidfile related functions.
      To avoid further growing util.c, this moves the pidfile related
      functions into a dedicated virpidfile.{c,h}. The functions are
      also all renamed to have 'virPidFile' as their name prefix
      
      * util/util.h, util/util.c: Remove all pidfile code
      * util/virpidfile.c, util/virpidfile.h: Add new APIs for pidfile
        handling.
      * lxc/lxc_controller.c, lxc/lxc_driver.c, network/bridge_driver.c,
        qemu/qemu_process.c: Add virpidfile.h include and adapt for API
        renames
      f80a4ed7
  3. 12 8月, 2011 1 次提交
    • E
      qemu: silence clang false positive · 398ce48d
      Eric Blake 提交于
      Our logic throws off analyzer tools:
      
      ptr var = NULL;
      if (flags == 0) flags = live ? _LIVE : _CONFIG;
      if (flags & _LIVE) do stuff
      if (flags & _CONFIG) var = non-null;
      if (flags & _LIVE) do more stuff
      else if (flags & _CONFIG) use var
      
      the tools keep thinking that var can still be NULL in the last
      if clause, adding the hint shuts them up.
      
      * src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Add a
      static analysis hint.
      398ce48d
  4. 11 8月, 2011 2 次提交
    • C
      qemu: Fix -chardev udp if parameters are omitted · d30d5726
      Cole Robinson 提交于
      The following XML:
      
          <serial type='udp'>
            <source mode='connect' service='9999'/>
          </serial>
      
      is accepted by domain_conf.c but maps to the qemu command line:
      
      -chardev udp,host=127.0.0.1,port=2222,localaddr=(null),localport=(null)
      
      qemu can cope with everything omitting except the connection port, which
      seems to also be the intent of domain_conf validation, so let's not
      generate bogus command lines for that case.
      The defaults are empty strings for addresses and 0 for the localport
      
      Additionally, tweak the qemu cli parsing to handle omitted host
      parameters
      for -serial udp
      d30d5726
    • E
      managedsave: prohibit use on transient domains · 0de75e85
      Eric Blake 提交于
      Transient domains reject attempts to set autostart, and using
      virDomainCreate to restart a domain only works on persistent
      domains.  Therefore, managed save makes no sense on transient
      domains, and should be rejected up front rather than creating
      an otherwise unrecoverable managed save file.
      
      Besides, transient domains imply that a lot more management is
      being done by the upper layer; this includes the assumption
      that the upper layer is okay managing the saved state file
      created by virDomainSave, and does not need to use managed save.
      
      * src/libvirt.c: Document that transient domains are incompatible
      with managed save.
      * src/qemu/qemu_driver.c (qemuDomainManagedSave): Enforce it.
      * src/libxl/libxl_driver.c (libxlDomainManagedSave): Likewise.
      0de75e85
  5. 10 8月, 2011 2 次提交
    • E
      qemu: minor formatting cleanup · cdbb27e3
      Eric Blake 提交于
      I noticed some inconsistent use of 'else'.
      
      * src/qemu/qemu_driver.c (qemuCPUCompare)
      (qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot)
      (qemuDomainSnapshotDiscard): Match coding conventions.
      cdbb27e3
    • P
      Fix memory leak while scanning snapshots · 839a5295
      Philipp Hahn 提交于
      If a snapshot with the name already exists, virDomainSnapshotAssignDef()
      just returns NULL, in which case the snapshot definition is leaked.
      Currently this leak is not a big problem, since qemuDomainSnapshotLoad()
      is only called once during initial startup of libvirtd.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      839a5295
  6. 06 8月, 2011 1 次提交
  7. 05 8月, 2011 1 次提交
    • E
      qemu: avoid crash on process attach · 5ef1b6c5
      Eric Blake 提交于
      Detected by ccc-analyzer, reported by Alex Jia.
      
      qemuProcessStart always calls qemuProcessWaitForMonitor with a
      non-negative position, but qemuProcessAttach always calls with -1.
      In the latter case, there is no log file we can scrape, so we
      also should not be trying to scrape the logs if the qemu process
      died at the very end.
      
      * src/qemu/qemu_process.c (qemuProcessWaitForMonitor): Don't try
      to read from log in qemuProcessAttach case.
      5ef1b6c5
  8. 04 8月, 2011 2 次提交
  9. 03 8月, 2011 8 次提交
    • E
      qemu: silence coverity false positives · f768b4c3
      Eric Blake 提交于
      Coverity gets confused by our logic.  Add some hints to silence
      false positives.
      
      * src/qemu/qemu_driver.c (qemudDomainGetVcpuPinInfo): Add hint.
      (qemuDomainGetMemoryParameters): Likewise.
      f768b4c3
    • E
      qemu: avoid memory leaks · 2ea9409a
      Eric Blake 提交于
      Quite a few leaks detected by coverity.  For chr, the leaks were
      close enough to the allocations to plug in place; for disk, the
      leaks were separated from the allocation by enough other lines with
      intermediate failure cases that I refactored the cleanup instead.
      
      * src/qemu/qemu_command.c (qemuParseCommandLine): Plug leaks.
      2ea9409a
    • E
      qemu: plug child process leak on domain core dump · 0c1813f4
      Eric Blake 提交于
      Detected by Coverity.  Leak introduced by typo in commit 58e668d2.
      
      * src/qemu/qemu_driver.c (doCoreDump): Use correct function.
      0c1813f4
    • E
      qemu: remove dead code · 9a87657a
      Eric Blake 提交于
      Warning detected by Coverity.  No need for the NULL check, and
      removing it silences the warning without any semantic change.
      
      * src/qemu/qemu_migration.c (qemuMigrationFinish): All entries to
      endjob had non-NULL vm.
      9a87657a
    • E
      qemu: avoid null deref on block pull error · 9160573d
      Eric Blake 提交于
      Coverity detected that 5 of 6 callers of virJSONValueArrayGet checked
      for a NULL return; and that by not checking we risk a null deref
      during an error.  The error is unlikely since the prior call to
      virJSONValueArraySize would probably have already caught any botched
      JSON array parse, but better safe than sorry.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockJobInfo):
      Check for NULL.
      (qemuMonitorJSONExtractPtyPaths): Fix typo.
      9160573d
    • E
      fdstream: drop delete argument · 00ef048f
      Eric Blake 提交于
      Revert 6a1f5f56.  Now that libvirt_iohelper takes fds by
      inheritance rather than by open() (commit 1eb66479), there is
      no longer a race where the parent can unlink() a file prior to
      the iohelper open()ing the same file.  From there, it makes
      more sense to have the callers both create and unlink, rather
      than the caller create and the stream unlink, since the latter
      was only needed when iohelper had to do the unlink.
      
      * src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile):
      Callers are responsible for deletion.
      * src/fdstream.c (virFDStreamOpenFileInternal): Don't leak created
      file on failure.
      (virFDStreamOpenFile, virFDStreamCreateFile): Drop parameter.
      * src/lxc/lxc_driver.c (lxcDomainOpenConsole): Update callers.
      * src/qemu/qemu_driver.c (qemuDomainScreenshot)
      (qemuDomainOpenConsole): Likewise.
      * src/storage/storage_driver.c (storageVolumeDownload)
      (storageVolumeUpload): Likewise.
      * src/uml/uml_driver.c (umlDomainOpenConsole): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
      00ef048f
    • E
      screenshot: don't unlink bogus file · 440d6b6a
      Eric Blake 提交于
      The previous qemu patch could end up calling unlink(tmp) before
      tmp was the name of a valid file (unlinking a fileXXXXXX template
      instead), or calling unlink(tmp) twice on success (once here,
      and once at the end of the stream).  Meanwhile, vbox also suffered
      from the same leaked tmp file bug.
      
      * src/qemu/qemu_driver.c (qemuDomainScreenshot): Don't unlink on
      success, or on invalid name.
      * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Don't leak temp file.
      440d6b6a
    • M
      qemu: Unlink temporary file on failure · d68b97c8
      Michal Privoznik 提交于
      Although virFDStreamOpenFile will unlink it once opened, when we hit
      error path, we must unlink it by hand.
      d68b97c8
  10. 01 8月, 2011 5 次提交
    • E
      qemu: fix crash when mixing sync and async monitor jobs · 193cd0f3
      Eric Blake 提交于
      Currently, we attempt to run sync job and async job at the same time. It
      means that the monitor commands for two jobs can be run in any order.
      
      In the function qemuDomainObjEnterMonitorInternal():
          if (priv->job.active == QEMU_JOB_NONE && priv->job.asyncJob) {
              if (qemuDomainObjBeginNestedJob(driver, obj) < 0)
      We check whether the caller is an async job by priv->job.active and
      priv->job.asynJob. But when an async job is running, and a sync job is
      also running at the time of the check, then priv->job.active is not
      QEMU_JOB_NONE. So we cannot check whether the caller is an async job
      in the function qemuDomainObjEnterMonitorInternal(), and must instead
      put the burden on the caller to tell us when an async command wants
      to do a nested job.
      
      Once the burden is on the caller, then only async monitor enters need
      to worry about whether the VM is still running; for sync monitor enter,
      the internal return is always 0, so lots of ignore_value can be dropped.
      
      * src/qemu/THREADS.txt: Reflect new rules.
      * src/qemu/qemu_domain.h (qemuDomainObjEnterMonitorAsync): New
      prototype.
      * src/qemu/qemu_process.h (qemuProcessStartCPUs)
      (qemuProcessStopCPUs): Add parameter.
      * src/qemu/qemu_migration.h (qemuMigrationToFile): Likewise.
      (qemuMigrationWaitForCompletion): Make static.
      * src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal): Add
      parameter.
      (qemuDomainObjEnterMonitorAsync): New function.
      (qemuDomainObjEnterMonitor, qemuDomainObjEnterMonitorWithDriver):
      Update callers.
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal)
      (qemudDomainCoreDump, doCoreDump, processWatchdogEvent)
      (qemudDomainSuspend, qemudDomainResume, qemuDomainSaveImageStartVM)
      (qemuDomainSnapshotCreateActive, qemuDomainRevertToSnapshot):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessStopCPUs)
      (qemuProcessFakeReboot, qemuProcessRecoverMigration)
      (qemuProcessRecoverJob, qemuProcessStart): Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationToFile)
      (qemuMigrationWaitForCompletion, qemuMigrationUpdateJobStatus)
      (qemuMigrationJobStart, qemuDomainMigrateGraphicsRelocate)
      (doNativeMigrate, doTunnelMigrate, qemuMigrationPerformJob)
      (qemuMigrationPerformPhase, qemuMigrationFinish)
      (qemuMigrationConfirm): Likewise.
      * src/qemu/qemu_hotplug.c: Drop unneeded ignore_value.
      193cd0f3
    • A
      qemu: fix return value issue · c03f7f13
      Alex Jia 提交于
      whether or not previous return value is -1, the following codes will be
      executed for a inactive guest in src/qemu/qemu_driver.c:
      ret = virDomainSaveConfig(driver->configDir, persistentDef);
      and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
      will be overwritten, this patch will fix this issue.
      
      * src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
        in out of blkio weight range for a inactive guest.
      
      * how to reproduce?
        % virsh blkiotune ${guestname} --weight 10
        % echo $?
      
        Note: guest must be inactive, argument 10 in out of blkio weight range,
        and can get a error information by checking libvirtd.log, however,
        virsh hasn't raised any error information, and return value is 0.
      
        https://bugzilla.redhat.com/show_bug.cgi?id=726304Signed-off-by: NAlex Jia <ajia@redhat.com>
      c03f7f13
    • A
      qemu: fix return value issue in qemuDomainSetMemoryParameters · 868453db
      Alex Jia 提交于
      whether or not previous return value is -1, the following codes will be
      executed for a inactive guest in qemuDomainSetMemoryParameters:
      ret = virDomainSaveConfig(driver->configDir, persistentDef);
      and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
      will be overwritten, this patch will fix this issue.
      
      * src/qemu/qemu_driver.c: avoid return value is overwritten when set
        min_guarante value to a inactive guest.
      
      * how to reproduce?
        % virsh memtune ${guestname} --min_guarante 1024
        % echo $?
      
        Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented
        in memory tunable, and I can get the error when check actual libvirtd.log,
        however, virsh hasn't raised any error information, and return value is 0.
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      868453db
    • G
      Correct the default value of lock_manager in qemu.conf · 2f6239d0
      Guannan Ren 提交于
      * src/qemu/qemu.conf: switch back the comment for the default lock
        manager to sanlock
      2f6239d0
    • O
      qemu: Fix a regression of domjobabort · f362a99a
      Osier Yang 提交于
      Introduced by f9a837da, the condition is not changed after
      the else clause is removed. So now it quit with "domain is not
      running" when the domain is running. However, when the domain is
      not running, it reports "no job is active".
      
      How to reproduce:
      
      1)
      % virsh start $domain
      % virsh domjobabort $domain
      error: Requested operation is not valid: domain is not running
      
      2)
      % virsh destroy $domain
      % virsh domjobabort $domain
      error: Requested operation is not valid: no job is active on the domain
      
      3)
      % virsh save $domain /tmp/$domain.save
      
      Before above commands finished, try to abort job in another terminal
      
      % virsh domabortjob $domain
      error: Requested operation is not valid: domain is not running
      f362a99a
  11. 30 7月, 2011 1 次提交
    • E
      conf: make 'vnet' prefix a macro · dd20328f
      Eric Blake 提交于
      Using a macro ensures that all the code is looking for the same
      prefix.
      
      * src/conf/domain_conf.h (VIR_NET_GENERATED_PREFIX): New macro.
      * src/conf/domain_conf.c (virDomainNetDefParseXML): Use it.
      * src/uml/uml_conf.c (umlConnectTapDevice): Likewise.
      * src/qemu/qemu_command.c (qemuNetworkIfaceConnect): Likewise.
      Suggested by Laine Stump.
      dd20328f
  12. 29 7月, 2011 4 次提交
    • E
      save: let qemu driver manipulate save files · f0a5eaf3
      Eric Blake 提交于
      The goal here is that save-image-dumpxml fed back to
      save-image-define should not change the save file; anywhere that
      this is not the case is probably a bug in domain_conf.c.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveImageGetXMLDesc)
      (qemuDomainSaveImageDefineXML): New functions.
      (qemuDomainSaveImageOpen): Add parameter.
      (qemuDomainRestoreFlags, qemuDomainObjRestore): Adjust clients.
      f0a5eaf3
    • E
      save: support qemu modifying xml on domain save/restore · 0ea479f8
      Eric Blake 提交于
      With this, it is possible to update the path to a disk backing
      image on either the save or restore action, without having to
      binary edit the XML embedded in the state file.
      
      This also modifies virDomainSave to output a smaller xml (only
      the inactive xml, which is all the more virDomainRestore parses),
      while still guaranteeing padding for most typical abi-compatible
      xml replacements, necessary so that the next patch for
      virDomainSaveImageDefineXML will not cause unnecessary
      modifications to the save image file.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal): Add parameter,
      only use inactive state, and guarantee padding.
      (qemuDomainSaveImageOpen): Add parameter.
      (qemuDomainSaveFlags, qemuDomainManagedSave)
      (qemuDomainRestoreFlags, qemuDomainObjRestore): Update callers.
      0ea479f8
    • L
      qemu: support type=network in domain graphics <listen> · 99e4b30b
      Laine Stump 提交于
      The domain XML now understands the <listen> subelement of its
      <graphics> element (including when listen type='network'), and the
      network driver has an internal API that will turn a network name into
      an IP address, so the final logical step is to put the glue into the
      qemu driver so that when it is starting up a domain, if it finds
      <listen type='network' network='xyz'/> in the XML, it will call the
      network driver to get an IPv4 address associated with network xyz, and
      tell qemu to listen for vnc (or spice) on that address rather than the
      default address (localhost).
      
      The motivation for this is that a large installation may want the
      guests' VNC servers listening on physical interfaces rather than
      localhost, so that users can connect directly from the outside; this
      requires sending qemu the appropriate IP address to listen on. But
      this address will of course be different for each host, and if a guest
      might be migrated around from one host to another, it's important that
      the guest's config not have any information embedded in it that is
      specific to one particular host. <listen type='network.../> can solve
      this problem in the following manner:
      
        1) on each host, define a libvirt network of the same name,
           associated with the interface on that host that should be used
           for listening (for example, a simple macvtap network: <forward
           mode='bridge' dev='eth0'/>, or host bridge network: <forward
           mode='bridge'/> <bridge name='br0'/>
      
        2) in the <graphics> element of each guest's domain xml, tell vnc to
           listen on the network name used in step 1:
      
           <graphics type='vnc' port='5922'>
             <listen type='network'network='example-net'/>
           </graphics>
      
      (all the above also applies for graphics type='spice').
      99e4b30b
    • L
      conf: add <listen> subelement to domain <graphics> element · ef79fb5b
      Laine Stump 提交于
      Once it's plugged in, the <listen> element will be an optional
      replacement for the "listen" attribute that graphics elements already
      have. If the <listen> element is type='address', it will have an
      attribute called 'address' which will contain an IP address or dns
      name that the guest's display server should listen on. If, however,
      type='network', the <listen> element should have an attribute called
      'network' that will be set to the name of a network configuration to
      get the IP address from.
      
      * docs/schemas/domain.rng: updated to allow the <listen> element
      
      * docs/formatdomain.html.in: document the <listen> element and its
        attributes.
      
      * src/conf/domain_conf.[hc]:
      
        1) The domain parser, formatter, and data structure are modified to
           support 0 or more <listen> subelements to each <graphics>
           element. The old style "legacy" listen attribute is also still
           accepted, and will be stored internally just as if it were a
           separate <listen> element. On output (i.e. format), the address
           attribute of the first <listen> element of type 'address' will be
           duplicated in the legacy "listen" attribute of the <graphic>
           element.
      
        2) The "listenAddr" attribute has been removed from the unions in
           virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
           This attribute is now in the <listen> subelement (aka
           virDomainGraphicsListenDef)
      
        3) Helper functions were written to provide simple access
           (both Get and Set) to the listen elements and their attributes.
      
      * src/libvirt_private.syms: export the listen helper functions
      
      * src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
        src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
        src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
      
        Modify all these files to use the listen helper functions rather
        than directly referencing the (now missing) listenAddr
        attribute. There can be multiple <listen> elements to a single
        <graphics>, but the drivers all currently only support one, so all
        replacements of direct access with a helper function indicate index
        "0".
      
      * tests/* - only 3 of these are new files added explicitly to test the
        new <listen> element. All the others have been modified to reflect
        the fact that any legacy "listen" attributes passed in to the domain
        parse will be saved in a <listen> element (i.e. one of the
        virDomainGraphicsListenDefs), and during the domain format function,
        both the <listen> element as well as the legacy attributes will be
        output.
      ef79fb5b
  13. 28 7月, 2011 4 次提交
    • E
      qemu: fix nested job with driver lock held · d9fcd17e
      Eric Blake 提交于
      qemuMigrationUpdateJobStatus (called in a loop by migration
      and save tasks) uses qemuDomainObjEnterMonitorWithDriver;
      however, that function ended up starting a nested job without
      releasing the driver.
      
      Since no one else is making nested calls, we can inline the
      internal functions to properly track driver_locked.
      
      * src/qemu/qemu_domain.h (qemuDomainObjBeginNestedJob)
      (qemuDomainObjBeginNestedJobWithDriver)
      (qemuDomainObjEndNestedJob): Drop unused prototypes.
      * src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal):
      Reflect driver lock to nested job.
      (qemuDomainObjBeginNestedJob)
      (qemuDomainObjBeginNestedJobWithDriver)
      (qemuDomainObjEndNestedJob): Drop unused functions.
      d9fcd17e
    • M
      qemu: Fix memory leak on metadata fetching · 09d7eba9
      Michal Privoznik 提交于
      As written in virStorageFileGetMetadataFromFD decription, caller
      must free metadata after use. Qemu driver miss this and therefore
      leak metadata which can grow to huge mem leak if somebody query
      for blockInfo a lot.
      09d7eba9
    • O
      qemu: Improve docs for virsh dump format · 01e1ea12
      Osier Yang 提交于
      The error in getCompressionType will never be reported, change
      the errors codes into warning (VIR_WARN("%s", _(foo)); doesn't break
      syntax-check rule), and also improve the docs in qemu.conf to tell
      user the truth.
      01e1ea12
    • E
      qemu: improve thread documentation · 9a34ebd3
      Eric Blake 提交于
      * src/qemu/THREADS.txt: Fix problems with typos, grammar, and
      outdated examples.
      9a34ebd3
  14. 27 7月, 2011 7 次提交