1. 10 8月, 2011 1 次提交
    • 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
  2. 03 8月, 2011 5 次提交
    • 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: 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
      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
  3. 01 8月, 2011 4 次提交
    • 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
    • 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
  4. 29 7月, 2011 2 次提交
    • 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
  5. 28 7月, 2011 2 次提交
    • 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
  6. 27 7月, 2011 7 次提交
  7. 26 7月, 2011 2 次提交
    • W
      set cpu bandwidth for the vm · 652e55b7
      Wen Congyang 提交于
      The cpu bandwidth is applied at the vcpu group level. We should apply it
      at the vm group level too, because the vm may do heavy I/O, and it will affect
      the other vm.
      
      We apply cpu bandwidth at the vcpu and the vm group level, so we must ensure
      that max(child_quota) <= parent_quota when we modify cpu bandwidth.
      652e55b7
    • E
      vcpu: teach getVcpusFlags about current · 59d04287
      Eric Blake 提交于
      Now that virDomainSetVcpusFlags knows about VIR_DOMAIN_AFFECT_CURRENT,
      so should virDomainGetVcpusFlags.
      
      Unfortunately, the virsh counterpart 'virsh vcpucount' has already
      commandeered --current for a different meaning, so teaching virsh
      to expose this in the next patch will require a bit of care.
      
      * src/libvirt.c (virDomainGetVcpusFlags): Allow
      VIR_DOMAIN_AFFECT_CURRENT.
      * src/libxl/libxl_driver.c (libxlDomainGetVcpusFlags): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainGetVcpusFlags): Likewise.
      * src/test/test_driver.c (testDomainGetVcpusFlags): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainGetVcpusFlags): Likewise.
      59d04287
  8. 25 7月, 2011 1 次提交
    • W
      rename cfs_* to vcpu_* · 2a667c34
      Wen Congyang 提交于
      In the XML file we now have
      
        <cputune>
          <shares>1024</shares>
          <period>90000</period>
          <quota>0</quota>
        </cputune>
      
      But the schedinfo parameter are being named
      
       cpu_shares: 1024
       cfs_period: 90000
       cfs_quota: 0
      
      The period/quota is per-vcpu value, so these new tunables should be named
      'vcpu_period' and 'vcpu_quota'.
      2a667c34
  9. 22 7月, 2011 7 次提交
    • A
      Implement virDomainBlockPull for the qemu driver · b976165c
      Adam Litke 提交于
      The virDomainBlockPull* family of commands are enabled by the
      following HMP/QMP commands: 'block_stream', 'block_job_cancel',
       'info block-jobs' / 'query-block-jobs', and 'block_job_set_speed'.
      
      * src/qemu/qemu_driver.c src/qemu/qemu_monitor_text.[ch]: implement disk
        streaming by using the proper qemu monitor commands.
      * src/qemu/qemu_monitor_json.[ch]: implement commands using the qmp monitor
      b976165c
    • E
      save: support bypass-cache flag in qemu.conf · a9f9545e
      Eric Blake 提交于
      When auto-dumping a domain on crash events, or autostarting a domain
      with managed save state, let the user configure whether to imply
      the bypass cache flag.
      
      * src/qemu/qemu.conf (auto_dump_bypass_cache, auto_start_bypass_cache):
      Document new variables.
      * src/qemu/libvirtd_qemu.aug (vnc_entry): Let augeas parse them.
      * src/qemu/qemu_conf.h (qemud_driver): Store new preferences.
      * src/qemu/qemu_conf.c (qemudLoadDriverConfig): Parse them.
      * src/qemu/qemu_driver.c (processWatchdogEvent, qemuAutostartDomain):
      Honor them.
      a9f9545e
    • E
      save: support BYPASS_CACHE during qemu save/restore · 58e668d2
      Eric Blake 提交于
      Wire together the previous patches to support file system cache
      bypass during API save/restore requests in qemu.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal, doCoreDump)
      (qemudDomainObjStart, qemuDomainSaveImageOpen, qemuDomainObjRestore)
      (qemuDomainObjStart): Add parameter.
      (qemuDomainSaveFlags, qemuDomainManagedSave, qemudDomainCoreDump)
      (processWatchdogEvent, qemudDomainStartWithFlags, qemuAutostartDomain)
      (qemuDomainRestoreFlags): Update callers.
      58e668d2
    • E
      save: wire up trivial save/restore flags implementations · b1083a4c
      Eric Blake 提交于
      For all hypervisors that support save and restore, the new API
      now performs the same functions as the old.
      
      VBox is excluded from this list, because its existing domainsave
      is broken (there is no corresponding domainrestore, and there
      is no control over the filename used in the save).  A later
      patch should change vbox to use its implementation for
      managedsave, and teach start to use managedsave results.
      
      * src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
      (libxlDomainSaveFlags): ...to new function.
      (libxlDomainRestore): Move guts...
      (libxlDomainRestoreFlags): ...to new function.
      * src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
      (testDomainRestore, testDomainRestoreFlags): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainSave)
      (xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
      (xenUnifiedDomainRestoreFlags): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
      Rename and move guts.
      (qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
      (qemuDomainRestoreFlags): ...here.
      (qemudDomainSaveFlag): Rename...
      (qemuDomainSaveInternal): ...to this, and update callers.
      b1083a4c
    • L
      qemu: use virDomainNetGetActual*() in qemuDomainXMLToNative · e9949a58
      Laine Stump 提交于
      This is the one function outside of domain_conf.c that plays around
      with (even modifying) the internals of the virDomainNetDef, and thus
      can't be fixed up simply by replacing direct accesses to the fields of
      the struct with the GetActual*() access functions.
      
      In this case, we need to check if the defined type is "network", and
      if it is *then* check the actual type; if the actual type is "bridge",
      then we can at least put the bridgename in a place where it can be
      used; otherwise (if type isn't "bridge"), we behave exactly as we used
      to - just null out *everything*.
      e9949a58
    • M
      destroy: Implement internal API for qemu driver · 427eaf13
      Michal Privoznik 提交于
      427eaf13
    • E
      build: rename files.h to virfile.h · 8e22e089
      Eric Blake 提交于
      In preparation for a future patch adding new virFile APIs.
      
      * src/util/files.h, src/util/files.c: Move...
      * src/util/virfile.h, src/util/virfile.c: ...here, and rename
      functions to virFile prefix.  Macro names are intentionally
      left alone.
      * *.c: All '#include "files.h"' uses changed.
      * src/Makefile.am (UTIL_SOURCES): Reflect rename.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
      * src/libvirt_private.syms: Likewise.
      * docs/hacking.html.in: Likewise.
      * HACKING: Regenerate.
      8e22e089
  10. 21 7月, 2011 4 次提交
  11. 20 7月, 2011 1 次提交
  12. 19 7月, 2011 1 次提交
    • E
      libvirt: do not mix internal flags into public API · 33ba6e68
      Eric Blake 提交于
      There were two API in driver.c that were silently masking flags
      bits prior to calling out to the drivers, and several others
      that were explicitly masking flags bits.  This is not
      forward-compatible - if we ever have that many flags in the
      future, then talking to an old server that masks out the
      flags would be indistinguishable from talking to a new server
      that can honor the flag.  In general, libvirt.c should forward
      _all_ flags on to drivers, and only the drivers should reject
      unknown flags.
      
      In the case of virDrvSecretGetValue, the solution is to separate
      the internal driver callback function to have two parameters
      instead of one, with only one parameter affected by the public
      API.  In the case of virDomainGetXMLDesc, it turns out that
      no one was ever mixing VIR_DOMAIN_XML_INTERNAL_STATUS with
      the dumpxml path in the first place; that internal flag was
      only used in saving and restoring state files, which happened
      to be in functions internal to a single file, so there is no
      mixing of the internal flag with a public flags argument.
      Additionally, virDomainMemoryStats passed a flags argument
      over RPC, but not to the driver.
      
      * src/driver.h (VIR_DOMAIN_XML_FLAGS_MASK)
      (VIR_SECRET_GET_VALUE_FLAGS_MASK): Delete.
      (virDrvSecretGetValue): Separate out internal flags.
      (virDrvDomainMemoryStats): Provide missing flags argument.
      * src/driver.c (verify): Drop unused check.
      * src/conf/domain_conf.h (virDomainObjParseFile): Delete
      declaration.
      (virDomainXMLInternalFlags): Move...
      * src/conf/domain_conf.c: ...here.  Delete redundant include.
      (virDomainObjParseFile): Make static.
      * src/libvirt.c (virDomainGetXMLDesc, virSecretGetValue): Update
      clients.
      (virDomainMemoryPeek, virInterfaceGetXMLDesc)
      (virDomainMemoryStats, virDomainBlockPeek, virNetworkGetXMLDesc)
      (virStoragePoolGetXMLDesc, virStorageVolGetXMLDesc)
      (virNodeNumOfDevices, virNodeListDevices, virNWFilterGetXMLDesc):
      Don't mask unknown flags.
      * src/interface/netcf_driver.c (interfaceGetXMLDesc): Reject
      unknown flags.
      * src/secret/secret_driver.c (secretGetValue): Update clients.
      * src/remote/remote_driver.c (remoteSecretGetValue)
      (remoteDomainMemoryStats): Likewise.
      * src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
      Likewise.
      * src/qemu/qemu_driver.c (qemudDomainMemoryStats): Likewise.
      * daemon/remote.c (remoteDispatchDomainMemoryStats): Likewise.
      33ba6e68
  13. 16 7月, 2011 3 次提交
    • O
      qemu: Fix a regression of attaching device · fab4f0c6
      Osier Yang 提交于
      The regression is introduced by Commit da1eba6b, the new
      codes with this commit doesn't reset "ret" to "-1" when
      it fails on parsing the device XML (live device attachment)
      
      This patch changes the codes to reset the "ret" and "-1",
      and also changes the codes so that it don't modify "ret"
      for condition checking.
      
      How to reproduce:
      
      % cat test.xml
      <disk type='oops' device='disk'>
        <driver name='qemu' type='raw'/>
        <source file='/var/lib/libvirt/images/test.img'/>
        <target dev='vda' bus='virtio'/>
      </disk>
      
      % virsh attach-device $domain test.xml
      Device attached successfully
      
      The device attachment failed actually with error "unknown disk type 'oops'",
      however, it reports success.
      fab4f0c6
    • E
      flags: fix qemu migration regression · 8d733f4e
      Eric Blake 提交于
      Commit f548480b broke migration v3 on qemu, because the driver
      passed flags on through to qemu_migration even though
      qemu_migration wasn't using those flags.
      
      * src/qemu/qemu_migration.h (QEMU_MIGRATION_FLAGS): New define.
      * src/qemu/qemu_driver.c: Simplify all migration callbacks.
      * src/qemu/qemu_migration.c (qemuMigrationConfirm): Fix regression.
      8d733f4e
    • E
      flags: use common dumpxml flags check · 461e0f1a
      Eric Blake 提交于
      The previous patches only cleaned up ATTRIBUTE_UNUSED flags cases;
      auditing the drivers found other places where flags was being used
      but not validated.  In particular, domainGetXMLDesc had issues with
      clients accepting a different set of flags than the common
      virDomainDefFormat helper function.
      
      * src/conf/domain_conf.c (virDomainDefFormat): Add common flag check.
      * src/uml/uml_driver.c (umlDomainAttachDeviceFlags)
      (umlDomainDetachDeviceFlags): Reject unknown
      flags.
      * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc)
      (vboxDomainAttachDeviceFlags)
      (vboxDomainDetachDeviceFlags): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainMemoryPeek): Likewise.
      (qemuDomainGetXMLDesc): Document common flag handling.
      * src/libxl/libxl_driver.c (libxlDomainGetXMLDesc): Likewise.
      * src/lxc/lxc_driver.c (lxcDomainGetXMLDesc): Likewise.
      * src/openvz/openvz_driver.c (openvzDomainGetXMLDesc): Likewise.
      * src/phyp/phyp_driver.c (phypDomainGetXMLDesc): Likewise.
      * src/test/test_driver.c (testDomainGetXMLDesc): Likewise.
      * src/vmware/vmware_driver.c (vmwareDomainGetXMLDesc): Likewise.
      * src/xenapi/xenapi_driver.c (xenapiDomainGetXMLDesc): Likewise.
      461e0f1a