1. 06 9月, 2014 1 次提交
    • E
      blockjob: split out block info monitor handling · ced81365
      Eric Blake 提交于
      Another layer of overly-multiplexed code that deserves to be
      split into obviously separate paths for query vs. modify.
      This continues the cleanup started in commit cefe0ba3.
      
      In the process, make some tweaks to simplify the logic when
      parsing the JSON reply.  There should be no user-visible
      semantic changes.
      
      * src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Drop parameter.
      (qemuMonitorBlockJobInfo): New prototype.
      (BLOCK_JOB_INFO): Drop enum.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob)
      (qemuMonitorJSONBlockJobInfo): Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Split...
      (qemuMonitorBlockJobInfo): ...into second function.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Move
      block info portions...
      (qemuMonitorJSONGetBlockJobInfo): ...here, and rename...
      (qemuMonitorJSONBlockJobInfo): ...and export.
      (qemuMonitorJSONGetBlockJobInfoOne): Alter return semantics.
      * src/qemu/qemu_driver.c (qemuDomainBlockPivot)
      (qemuDomainBlockJobImpl, qemuDomainGetBlockJobInfo): Adjust
      callers.
      * src/qemu/qemu_migration.c (qemuMigrationDriveMirror)
      (qemuMigrationCancelDriveMirror): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ced81365
  2. 05 9月, 2014 2 次提交
    • E
      blockjob: split out block info driver handling · cefe0ba3
      Eric Blake 提交于
      The qemu implementation for virDomainGetBlockJobInfo() has a
      minor bug: it grabs the qemu job with intent to QEMU_JOB_MODIFY,
      which means it cannot be run in parallel with any other
      domain-modifying command.  Among others, virDomainBlockJobAbort()
      is such a modifying command, and it defaults to being
      synchronous, and can wait as long as several seconds to ensure
      that the job has actually finished.  Due to the job rules, this
      means a user cannot obtain status about the job during that
      timeframe, even though we know that some client management code
      exists which is using a polling loop on status to see when a job
      finishes.
      
      This bug has been present ever since blockpull support was first
      introduced (commit b976165c, v0.9.4 in Jul 2011), all because we
      stupidly tried to cram too much multiplexing through a single
      helper routine, but was made worse in 97c59b9c (v1.2.7) when
      BlockJobAbort was fixed to wait longer.  It's time to disentangle
      some of the mess in qemuDomainBlockJobImpl, and in the process
      relax block job query to use QEMU_JOB_QUERY, since it can safely
      be used in parallel with any long running modify command.
      
      Technically, there is one case where getting block job info can
      modify domain XML - we do snooping to see if a 2-phase job has
      transitioned into the second phase, for an optimization in the
      case of old qemu that lacked an event for the transition.  I
      claim this optimization is safe (the jobs are all about modifying
      qemu state, not necessarily xml state); but if it proves to be
      a problem, we could use the difference between the capabilities
      QEMU_CAPS_BLOCKJOB_{ASYNC,SYNC} to determine whether we even
      need snooping, and only request a modifying job in the case of
      older qemu.
      
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Move info
      handling...
      (qemuDomainGetBlockJobInfo): ...here, and relax job type.
      (qemuDomainBlockJobAbort, qemuDomainBlockJobSetSpeed)
      (qemuDomainBlockRebase, qemuDomainBlockPull): Adjust callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cefe0ba3
    • E
      blockjob: shuffle block rebase code · 02d2bd7d
      Eric Blake 提交于
      The existing virDomainBlockRebase code rejected the combination of
      _RELATIVE and _COPY flags, but only by accident.  It makes sense
      to add support for the combination someday, at least for the case
      of _SHALLOW and not _REUSE_EXT; but to implement it, libvirt would
      have to pre-create the file with a relative backing name, and I'm
      not ready to code that in yet.
      
      Meanwhile, the code to forward on to the block copy code is getting
      longer, and reorganizing the function to have the block pull done
      early makes it easier to add even more block copy prep code.
      
      This patch should have no semantic difference other than the quality
      of the error message on the unsupported flag combination.  Pre-patch:
      
      error: unsupported flags (0x10) in function qemuDomainBlockCopy
      
      Post-patch:
      
      error: argument unsupported: Relative backing during copy not supported yet
      
      * src/qemu/qemu_driver.c (qemuDomainBlockRebase): Reorder code,
      and improve error message of relative copy.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      02d2bd7d
  3. 04 9月, 2014 2 次提交
    • E
      maint: use consistent if-else braces in qemu · 44e30277
      Eric Blake 提交于
      I'm about to add a syntax check that enforces our documented
      HACKING style of always using matching {} on if-else statements.
      
      This commit focuses on the qemu driver.
      
      * src/qemu/qemu_command.c (qemuParseISCSIString)
      (qemuParseCommandLineDisk, qemuParseCommandLine)
      (qemuBuildSmpArgStr, qemuBuildCommandLine)
      (qemuParseCommandLineDisk, qemuParseCommandLineSmp): Correct use
      of {}.
      * src/qemu/qemu_capabilities.c (virQEMUCapsProbeCPUModels):
      Likewise.
      * src/qemu/qemu_driver.c (qemuDomainCoreDumpWithFormat)
      (qemuDomainRestoreFlags, qemuDomainGetInfo)
      (qemuDomainMergeBlkioDevice): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextCreateSnapshot)
      (qemuMonitorTextLoadSnapshot, qemuMonitorTextDeleteSnapshot):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessStop): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      44e30277
    • W
      qemu_process: Resolve Coverity RESOURCE_LEAK · 4f2ad084
      Wang Rui 提交于
      If virSecurityManagerClearSocketLabel() fails, 'agent' won't
      be freed before jumping to cleanup.
      Signed-off-by: NWang Rui <moon.wangrui@huawei.com>
      4f2ad084
  4. 03 9月, 2014 1 次提交
  5. 02 9月, 2014 1 次提交
  6. 29 8月, 2014 3 次提交
    • J
      qemu_driver: Resolve Coverity FORWARD_NULL · 5c0dad7b
      John Ferlan 提交于
      In qemuDomainSnapshotCreateDiskActive() if we jumped to cleanup from a
      failed actions = virJSONValueNewArray(), then 'cfg' would be NULL.
      
      So just return -1, which in turn removes the need for cleanup:
      5c0dad7b
    • J
      qemu: Allow use of iothreads for disk definitions · ef8da2ad
      John Ferlan 提交于
      For virtio-blk-pci disks with the disk iothread attribute that are
      running the correct emulator, add the "iothread=iothread#" to the
      -device command line in order to enable iothreads for the disk as
      long as the command is available, the disk iothread value provided is
      valid, and is supported for the disk device being added
      ef8da2ad
    • J
      qemu: Add support for iothreads · 72edaae7
      John Ferlan 提交于
      Add a new capability to ensure the iothreads feature exists for the qemu
      emulator being run - requires the "query-iothreads" QMP command. Using the
      domain XML add correspoding command argument in order to generate the
      threads. The iothreads will use a name space "iothread#" where, the
      future patch to add support for using an iothread to a disk definition to
      merely define which of the available threads to use.
      
      Add tests to ensure the xml/argv processing is correct.  Note that no
      change was made to qemuargv2xmltest.c as processing the -object element
      would require knowing more than just iothreads.
      72edaae7
  7. 28 8月, 2014 12 次提交
    • P
      qemu: Implement bulk stats API and one of the stats groups to return · d1bde8ed
      Peter Krempa 提交于
      Implement the API function for virDomainListGetStats and
      virConnectGetAllDomainStats in a modular way and implement the
      VIR_DOMAIN_STATS_STATE group of statistics.
      
      Although it may look like the function looks universal I'd rather not
      expose it to other drivers as the coming stats groups are likely to do
      qemu specific stuff to obtain the stats.
      d1bde8ed
    • J
      qemu_command: Resolve Coverity DEADCODE · 84bfb11b
      John Ferlan 提交于
      One useless warning, but the other one rather pertinent. On entry
      the 'trans' variable is initialized to VIR_DOMAIN_DISK_TRANS_DEFAULT.
      When the "trans" was found in the parsing loop it def->geometry.trans
      was assigned to the return from virDomainDiskGeometryTransTypeFromString
      and then 'trans' was used to do the comparison to see if it was valid.
      
      So remove 'trans' and use def->geometry.trans properly
      84bfb11b
    • J
      qemu_driver: Resolve Coverity DEADCODE · ec10ff9e
      John Ferlan 提交于
      A bunch of false positives brought on by our own doings
      ec10ff9e
    • J
      qemu_monitor: Resolve Coverity NESTING_INDENT_MISMATCH · ee8b6245
      John Ferlan 提交于
      The PROBE macro can expand to more than one line/statement - put curly
      braces around the if statement to be safe
      ee8b6245
    • J
      qemu_driver: Resolve Coverity RESOURCE_LEAK · 69e433bc
      John Ferlan 提交于
      Coverity found that the 'buf' wasn't VIR_FREE'd at exit.
      69e433bc
    • J
      qemu_capabilities: Resolve Coverity RESOURCE_LEAK · 2f7ced36
      John Ferlan 提交于
      Coverity determined that on error path that 'mach' wouldn't be free'd
      Since virCapabilitiesFreeGuestMachine() isn't globally available, we'll
      insert first and then if the VIR_STRDUP's fail they it will eventually
      cause the 'mach' to be freed in the error path
      2f7ced36
    • J
      qemu_agent: Resolve Coverity RESOURCE_LEAK · 6f8a4f6d
      John Ferlan 提交于
      Coverity found that on error paths, the 'arg' value wasn't be cleaned
      up. Followed the example in qemuAgentSetVCPUs() where upon successful call
      to qemuAgentCommand() the 'cpus' is set to NULL; otherwise, when cleanup
      occurs the free the memory for 'arg'
      6f8a4f6d
    • J
      qemu_command: Resolve Coverity RESOURCE_LEAK · 461fb555
      John Ferlan 提交于
      In qemuParseISCSIString() if an error was returned, then the call
      to qemuParseDriveURIString() where the uri is free'd wouldn't be run
      461fb555
    • W
      qemu_capabilities: Resolve Coverity RESOURCE_LEAK · 6781d5b5
      Wang Rui 提交于
      In function virQEMUCapsParseMachineTypesStr, VIR_STRNDUP allocates
      memory for 'name' in {do,while} loop. If 'name' isn't freed before
      'continue', its memory will be allocated again in the next loop.
      In this case the memory allocated for 'name' in privious loop is
      useless and not freed. Free it before continue this loop to fix that.
      Signed-off-by: NWang Rui <moon.wangrui@huawei.com>
      6781d5b5
    • J
      qemu_capabilities: Resolve Coverity NULL_RETURNS · cabebc0c
      John Ferlan 提交于
      Adjust the initialization of qemuCaps() to check for a NULL before
      attempting to dereference like other callers/users do.
      cabebc0c
    • J
      qemu_driver: Resolve Coverity CONSTANT_EXPRESSION_RESULT · 9d7254de
      John Ferlan 提交于
      The call to virDomainSnapshotRedefinePrep() had a spurrious ! in front of
      it which caused Coverity to complan that the expression is always false.
      9d7254de
    • J
      qemu_command: Resolve Coverity REVERSE_INULL · 39b9c121
      John Ferlan 提交于
      In qemuNetworkIfaceConnect() a call to virNetDevBandwidthSet() is
      made where the function prototype requires the first parameter
      (net->ifname) to be non NULL.  Coverity complains that the subsequent
      non NULL check for net->ifname prior to the next call gets flagged as
      an unnecessary check.  Resolve by removing the extra check
      39b9c121
  8. 27 8月, 2014 3 次提交
  9. 26 8月, 2014 2 次提交
    • E
      blkdeviotune: check for overflow when parsing XML · 2f0944de
      Erik Skultety 提交于
      According to docs/schemas/domaincommon.rng and _virDomainBlockIoTuneInfo
      all the iotune values are interpreted as unsigned long long, however
      according to qemu_monitor_json.c, qemu silently truncates numbers
      larger than LLONG_MAX. There's really not much of a usage for such
      large numbers anyway yet. This patch provides the same overflow
      check during a domain start as it does during setting
      a blkdeviotune element in qemu_driver.c and thus reports an error when
      a larger number than LLONG_MAX is detected.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1131876
      2f0944de
    • A
      Add new 'kvm' domain feature and ability to hide KVM signature · d0711642
      Alex Williamson 提交于
      QEMU 2.1 added support for the kvm=off option to the -cpu command,
      allowing the KVM hypervisor signature to be hidden from the guest.
      This enables disabling of some paravirualization features in the
      guest as well as allowing certain drivers which test for the
      hypervisor to load.  Domain XML syntax is as follows:
      
      <domain type='kvm>
        ...
        <features>
          ...
          <kvm>
            <hidden state='on'/>
          </kvm>
        </features>
        ...
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      d0711642
  10. 25 8月, 2014 2 次提交
  11. 23 8月, 2014 1 次提交
    • E
      qemu: check for active domain after agent interaction · 2c551d34
      Eric Blake 提交于
      Commit b606bbb4 reminded me that any time we drop locks to run
      back-to-back guest interaction commands, we have to check that
      the guest didn't disappear in between the two commands.  A quick
      audit found a couple of spots that were missing this check.
      
      * src/qemu/qemu_driver.c (qemuDomainShutdownFlags)
      (qemuDomainSetVcpusFlags): Check that domain is still up.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2c551d34
  12. 22 8月, 2014 2 次提交
  13. 21 8月, 2014 1 次提交
    • J
      Perform disk config validity checking for attach-device config · 33188c9f
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1078126
      
      Using 'virsh attach-device --config' (or --persistent) to attach a
      file backed lun device will succeed; however, subsequent domain restarts
      will result in failure because the configuration of a file backed lun
      is not supported.
      
      Although allowing 'illegal configurations' is something that can be
      allowed, it may not be practical in this case. Generally, when attaching
      a device to a domain means the domain must be running. A way around
      this is using the --config (or --persistent) option. When an attach
      is done to a running domain, a temporary configuration is modified
      first followed by the live update. The live update will make a number
      of disk validity checks when building the qemu command to attach the
      disk. If any fail, then change is rejected.
      
      Rather than allow a potentially illegal combination, adjust the code
      in the configuration path to make the same checks as the running path
      will make with respect to disk validity checks. This way we avoid
      having the potential for some subsequent start/reboot to fail because
      an illegal combination was allowed.
      
      NB: The live path still checks the configuration since it is possible
      to just do --live guest modification...
      33188c9f
  14. 20 8月, 2014 7 次提交