1. 16 4月, 2012 6 次提交
    • M
      qemuProcessStart: Switch to flags instead of bunch booleans · 63ddc65d
      Michal Privoznik 提交于
      Currently, we have 3 boolean arguments we have to pass
      to qemuProcessStart(). As libvirt grows it is harder and harder
      to remember them and their position. Therefore we should
      switch to flags instead.
      63ddc65d
    • C
      storage: lvm: use correct lv* command parameters · cab1a9de
      Cole Robinson 提交于
      lvcreate want's the parent pool's name, not the pool path
      lvchange and lvremove want lv specified as $vgname/$lvname
      
      This largely worked before because these commands strip off a
      starting /dev. But https://bugzilla.redhat.com/show_bug.cgi?id=714986
      is from a user using a 'nested VG' that was having problems.
      
      I couldn't find any info on nested LVM and the reporter never responded,
      but I reproduced with XML that specified a valid source name, and
      set target path to a symlink.
      cab1a9de
    • O
      qemu: Avoid the memory allocation and freeing · 6fbd5737
      Osier Yang 提交于
      6fbd5737
    • O
      numad: Ignore cpuset if placement is auto · 8fb2164c
      Osier Yang 提交于
      As explained in previous patch, numad will balance the affinity
      dynamically, so reflecting the cpuset from numad at the first
      time doesn't make much case, and may just could cause confusion.
      8fb2164c
    • O
      numad: Convert node list to cpumap before setting affinity · ccf80e36
      Osier Yang 提交于
      Instead of returning a CPUs list, numad returns NUMA node
      list instead, this patch is to convert the node list to
      cpumap before affinity setting. Otherwise, the domain
      processes will be pinned only to CPU[$numa_cell_num],
      which will cause significiant performance losses.
      
      Also because numad will balance the affinity dynamically,
      reflecting the cpuset from numad back doesn't make much
      sense then, and it may just could produce confusion for
      the users. Thus the better way is not to reflect it back
      to XML. And in this case, it's better to ignore the cpuset
      when parsing XML.
      
      The codes to update the cpuset is removed in this patch
      incidentally, and there will be a follow up patch to ignore
      the manually specified "cpuset" if "placement" is "auto",
      and document will be updated too.
      ccf80e36
    • G
      openvz: wire up more node information functions · b33d3d0f
      Guido Günther 提交于
      in detail nodeGetCPUStats, nodeGetMemoryStats, nodeGetCellsFreeMemory
      and nodeGetFreeMemory
      b33d3d0f
  2. 14 4月, 2012 1 次提交
    • P
      virnetdev: Check for defined IFLA_VF_* · d7451bdd
      Philipp Hahn 提交于
      The linux-2.6.32 kernel header does not yet define IFLA_VF_MAX and others,
      which breaks compiling a new libvirt on old systems like Debian Squeeze.
      
      (I also have to add --without-macvtap --disable-werror --without-virtualport to
       ./configure to get it to compile.)
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      d7451bdd
  3. 13 4月, 2012 4 次提交
  4. 12 4月, 2012 6 次提交
    • M
      qemuOpenFile: Don't force chown on NFS · b1256816
      Michal Privoznik 提交于
      If dynamic_ownership is off and we are creating a file on NFS
      we force chown. This will fail as chown/chmod are not supported
      on NFS. However, with no dynamic_ownership we are not required
      to do any chown.
      b1256816
    • E
      blockjob: allow for fast-finishing job · a9d3495e
      Eric Blake 提交于
      In my testing, I was able to provoke an odd block pull failure:
      
      $ virsh blockpull dom vda --bandwidth 10000
      error: Requested operation is not valid: No active operation on device: drive-virtio-disk0
      
      merely by using gdb to artifically wait to do the block job set speed
      until after the pull had already finished.  But in reality, that should
      be a success, since the pull finished before we had a chance to set
      speed.  Furthermore, using a double job lock is not only annoying, but
      a bug in itself - if you do parallel virDomainBlockRebase, and hit
      the race window just right, the first call grabs the VM job to start
      a fast block job, then the second call grabs the VM job to start
      a long-running job with unspecified speed, then the first call finally
      regrabs the VM job and sets the speed, which ends up running the
      second job under the speed from the first call.  By consolidating
      things into a single job, we avoid opening that race, as well as reduce
      the time between starting the job and changing the speed, for less
      likelihood of the speed change happening after block job completion
      in the first place.
      
      * src/qemu/qemu_monitor.h (BLOCK_JOB_CMD): Add new mode.
      * src/qemu/qemu_driver.c (qemuDomainBlockRebase): Move secondary
      job call...
      (qemuDomainBlockJobImpl): ...here, for fewer locks.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Change
      return value on new internal mode.
      a9d3495e
    • E
      blockjob: wire up qemu async virDomainBlockJobAbort · a91ce852
      Eric Blake 提交于
      Without the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag, libvirt will internally
      poll using qemu's "query-block-jobs" API and will not return until the
      operation has been completed.  API users are advised that this operation
      is unbounded and further interaction with the domain during this period
      may block.  Future patches may refactor things to allow other queries in
      parallel with this polling.  For older qemu, we synthesize the cancellation
      event, since qemu won't generate it.
      
      The choice of polling duration copies from the code in qemu_migration.c.
      Signed-off-by: NAdam Litke <agl@us.ibm.com>
      Cc: Stefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a91ce852
    • E
      blockjob: optimize JSON event handler lookup · ecb39e9d
      Eric Blake 提交于
      Probably in the noise, but this will let us scale more efficiently
      as we learn to recognize even more qemu events.
      
      * src/qemu/qemu_monitor_json.c (eventHandlers): Sort.
      (qemuMonitorEventCompare): New helper function.
      (qemuMonitorJSONIOProcessEvent): Optimize event lookup.
      ecb39e9d
    • A
      blockjob: add API for async virDomainBlockJobAbort · a696f8b7
      Adam Litke 提交于
      Block job cancellation can take a while.  Now that upstream qemu 1.1
      has asynchronous block cancellation, we want to expose that to the user.
      Therefore, the following updates are made to the virDomainBlockJob API:
      
      A new block job event type VIR_DOMAIN_BLOCK_JOB_CANCELED is managed by
      libvirt.  Regardless of the flags used with virDomainBlockJobAbort, this
      event will be raised: 1. when using synchronous block_job_cancel (the
      event will be synthesized by libvirt), and 2. whenever it is received
      from qemu (via asynchronous block-job-cancel).  Note that the event
      may be detected by libvirt even before the virDomainBlockJobAbort
      completes (always true when it is synthesized, but also possible if
      cancellation was fast).
      
      A new extension flag VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC is added to the
      virDomainBlockJobAbort API.  When enabled, this function will allow
      (but not require) asynchronous operation (ie, it returns as soon as
      possible, which might be before the job has actually been canceled).
      When the API is used in this mode, it is the responsibility of the
      caller to wait for a VIR_DOMAIN_BLOCK_JOB_CANCELED event or poll via
      the virDomainGetBlockJobInfo API to check the cancellation status.
      
      This patch also exposes the new flag through virsh, and makes virsh
      slightly easier to use (--async implies --abort, and lack of any options
      implies --info), although it leaves the qemu implementation for later
      patches.
      Signed-off-by: NAdam Litke <agl@us.ibm.com>
      Cc: Stefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a696f8b7
    • E
      blockjob: add qemu capabilities related to block pull jobs · 2b085f5b
      Eric Blake 提交于
      RHEL 6.2 was released with an early version of block jobs, which only
      worked on the qed file format, where the commands were spelled with
      underscore (contrary to QMP style), and where 'block_job_cancel' was
      synchronous and did not trigger an event.
      
      The upcoming qemu 1.1 release has fixed these short-comings [1][2]:
      the commands now work on multiple file types, are spelled with dash,
      and 'block-job-cancel' is asynchronous and emits an event upon conclusion.
      
      [1]qemu commit 370521a1d6f5537ea7271c119f3fbb7b0fa57063
      [2]https://lists.gnu.org/archive/html/qemu-devel/2012-04/msg01248.html
      
      This patch recognizes the new spellings, and fixes virDomainBlockRebase
      to give a graceful error when talking to a too-old qemu on a partial
      rebase attempt.  Fixes for the new semantics will come later.  This
      patch also removes a bogus ATTRIBUTE_NONNULL mistakenly added in
      commit 10ec36e2.
      
      * src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC)
      (QEMU_CAPS_BLOCKJOB_ASYNC): New bits.
      * src/qemu/qemu_capabilities.c (qemuCaps): Name them.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONCheckCommands): Set
      them.
      (qemuMonitorJSONBlockJob): Manage both command names.
      (qemuMonitorJSONDiskSnapshot): Minor formatting fix.
      * src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Alter signature.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Pass through
      capability bit.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update callers.
      2b085f5b
  5. 11 4月, 2012 4 次提交
    • P
      qemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection · 3d3de46a
      Peter Krempa 提交于
      The new safe console handling introduced a possibility to deadlock the
      qemu driver when a new console connection forcibly disconnects a
      previous console stream that belongs to an already closed connection.
      
      The virStreamFree function calls subsequently a the virReleaseConnect
      function that tries to lock the driver while discarding the connection,
      but the driver was already locked in qemuDomainOpenConsole.
      
      Backtrace of the deadlocked thread:
      0  0x00007f66e5aa7f14 in __lll_lock_wait () from /lib64/libpthread.so.0
      1  0x00007f66e5aa3411 in _L_lock_500 () from /lib64/libpthread.so.0
      2  0x00007f66e5aa322a in pthread_mutex_lock () from/lib64/libpthread.so.0
      3  0x0000000000462bbd in qemudClose ()
      4  0x00007f66e6e178eb in virReleaseConnect () from/usr/lib64/libvirt.so.0
      5  0x00007f66e6e19c8c in virUnrefStream () from /usr/lib64/libvirt.so.0
      6  0x00007f66e6e3d1de in virStreamFree () from /usr/lib64/libvirt.so.0
      7  0x00007f66e6e09a5d in virConsoleHashEntryFree () from/usr/lib64/libvirt.so.0
      8  0x00007f66e6db7282 in virHashRemoveEntry () from/usr/lib64/libvirt.so.0
      9  0x00007f66e6e09c4e in virConsoleOpen () from /usr/lib64/libvirt.so.0
      10 0x00000000004526e9 in qemuDomainOpenConsole ()
      11 0x00007f66e6e421f1 in virDomainOpenConsole () from/usr/lib64/libvirt.so.0
      12 0x00000000004361e4 in remoteDispatchDomainOpenConsoleHelper ()
      13 0x00007f66e6e80375 in virNetServerProgramDispatch () from/usr/lib64/libvirt.so.0
      14 0x00007f66e6e7ae11 in virNetServerHandleJob () from/usr/lib64/libvirt.so.0
      15 0x00007f66e6da897d in virThreadPoolWorker () from/usr/lib64/libvirt.so.0
      16 0x00007f66e6da7ff6 in virThreadHelper () from/usr/lib64/libvirt.so.0
      17 0x00007f66e5aa0c5c in start_thread () from /lib64/libpthread.so.0
      18 0x00007f66e57e7fcd in clone () from /lib64/libc.so.6
      
      * src/qemu/qemu_driver.c: qemuDomainOpenConsole()
              -- unlock the qemu driver right after acquiring the domain
              object
      3d3de46a
    • J
      qemu: Warn on possibly incorrect usage of EnterMonitor* · 6eede368
      Jiri Denemark 提交于
      qemuDomainObjEnterMonitor{,WithDriver} should not be called from async
      jobs, only EnterMonitorAsync variant is allowed.
      6eede368
    • J
      qemu: Track job owner for better debugging · 08ec1d78
      Jiri Denemark 提交于
      In case an API fails with "cannot acquire state change lock", searching
      for the API that possibly forgot to end its job is not always easy.
      Let's keep track of the job owner and print it out for easier
      identification.
      08ec1d78
    • J
      qemu: Avoid excessive calls to qemuDomainObjSaveJob() · 31796e2c
      Jiri Denemark 提交于
      As reported by Daniel Berrangé, we have a huge performance regression
      for virDomainGetInfo() due to the change which makes virDomainEndJob()
      save the XML status file every time it is called. Previous to that
      change, 2000 calls to virDomainGetInfo() took ~2.5 seconds. After that
      change, 2000 calls to virDomainGetInfo() take 2 *minutes* 45 secs.
      
      We made the change to be able to recover from libvirtd restart in the
      middle of a job. However, only destroy and async jobs are taken care of.
      Thus it makes more sense to only save domain state XML when these jobs
      are started/stopped.
      31796e2c
  6. 10 4月, 2012 4 次提交
  7. 06 4月, 2012 4 次提交
    • E
      snapshot: fix memory leak on error · 14135609
      Eric Blake 提交于
      Leak introduced in commit 0436d328.  If we allocate an actions array,
      but fail early enough to never consume it with the qemu monitor
      transaction call, we leaked memory.
      
      But our semantics of making the transaction command free the caller's
      memory is awkward; avoiding the memory leak requires making every
      intermediate function in the call chain check for error.  It is much
      easier to fix things so that the function that allocates also frees,
      while the call chain leaves the caller's data intact.  To do that,
      I had to hack our JSON data structure to make it easy to protect a
      portion of an arbitrary JSON tree from being freed.
      
      * src/util/json.h (virJSONType): Name the enum.
      (_virJSONValue): New field.
      * src/util/json.c (virJSONValueFree): Use it to protect a portion
      of an array.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONTransaction): Avoid
      freeing caller's data.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive):
      Free actions array on failure.
      14135609
    • M
      qemu_ga: Don't overwrite errors on FSThaw · 650da0e9
      Michal Privoznik 提交于
      We can tell qemuDomainSnapshotFSThaw if we want it to report errors or
      not. However, if we don't want to and an error has been already set by
      previous qemuReportError() we must keep copy of that error not just a
      pointer to it. Otherwise, it get overwritten if FSThaw reports an error.
      650da0e9
    • S
      xen config: No vfb in HVM guest configuration · fb98da00
      Stefan Bader 提交于
      This causes an implicit vkbd device to be added which takes
      6min to finally fail being initialized in the guest.
      
      http://lists.xen.org/archives/html/xen-devel/2012-04/msg00409.htmlSigned-off-by: NStefan Bader <stefan.bader@canonical.com>
      fb98da00
    • G
      virURIParse: don't forget to copy the user part · 4eb1c256
      Guido Günther 提交于
      This got dropped with 300e60e1
      
      Cheers,
       -- Guido
      4eb1c256
  8. 05 4月, 2012 2 次提交
    • A
      conf: Plug memory leaks on virDomainDiskDefParseXML · 80d476a9
      Alex Jia 提交于
      Detected by valgrind. Leaks are introduced in commit b22eaa75.
      
      * src/conf/domain_conf.c (virDomainDiskDefParseXML): fix memory leaks.
      
      How to reproduce?
      
      % make && make -C tests check TESTS=qemuxml2argvtest
      % cd tests && valgrind -v --leak-check=full ./qemuxml2argvtest
      
      actual result:
      
      ==2143== 12 bytes in 2 blocks are definitely lost in loss record 74 of 179
      ==2143==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
      ==2143==    by 0x39D90A67DD: xmlStrndup (xmlstring.c:45)
      ==2143==    by 0x4F5EC0: virDomainDiskDefParseXML (domain_conf.c:3438)
      ==2143==    by 0x502F00: virDomainDefParseXML (domain_conf.c:8304)
      ==2143==    by 0x505FE3: virDomainDefParseNode (domain_conf.c:9080)
      ==2143==    by 0x5069AE: virDomainDefParse (domain_conf.c:9030)
      ==2143==    by 0x41CBF4: testCompareXMLToArgvHelper (qemuxml2argvtest.c:105)
      ==2143==    by 0x41E5DD: virtTestRun (testutils.c:145)
      ==2143==    by 0x416FA3: mymain (qemuxml2argvtest.c:399)
      ==2143==    by 0x41DCB7: virtTestMain (testutils.c:700)
      ==2143==    by 0x39CF01ECDC: (below main) (libc-start.c:226)
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      80d476a9
    • I
      openvz: support vzctl 3.1 · 37075dfe
      Ilja Livenson 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=809895
      
      Basically, openvz dropped strict version numbering (3.1 vs 3.1.0),
      which caused parsing to fail.
      37075dfe
  9. 04 4月, 2012 4 次提交
  10. 03 4月, 2012 1 次提交
    • J
      qemu: Start nested job in qemuDomainCheckEjectableMedia · 66cab01a
      Jiri Denemark 提交于
      Originally, qemuDomainCheckEjectableMedia was entering monitor with qemu
      driver lock. Commit 2067e31b, which I
      made to fix that, revealed another issue we had (but didn't notice it
      since the driver was locked): we didn't set nested job when
      qemuDomainCheckEjectableMedia is called during migration. Thus the
      original fix I made was wrong.
      66cab01a
  11. 02 4月, 2012 4 次提交
    • P
      Xen: Fix <clock> handling · 11ec6bd8
      Philipp Hahn 提交于
      XenD-3.1 introduced managed domains. HV-domains have rtc_timeoffset
      (hgd24f37b31030 from 2007-04-03), which tracks the offset between the
      hypervisors clock and the domains RTC, and is persisted by XenD.
      In combination with localtime=1 this had a bug until XenD-3.4
      (hg5d701be7c37b from 2009-04-01) (I'm not 100% sure how that bug
      manifests, but at least for me in TZ=Europe/Berlin I see the previous
      offset relative to utc being applied to localtime again, which manifests
      in an extra hour being added)
      
      XenD implements the following variants for clock/@offset:
      - PV domains don't have a RTC → 'localtime' | 'utc'
      - <3.1: no managed domains → 'localtime' | 'utc'
      - ≥3.1: the offset is tracked for HV → 'variable'
              due to the localtime=1 bug → 'localtime' | 'utc'
      - ≥3.4: the offset is tracked for HV → 'variable'
      
      Current libvirtd still thinks XenD only implements <clock offset='utc'/>
      and <clock offset='localtime'/>, which is wrong, since the semantic of
      'utc' and 'localtime' specifies, that the offset will be reset on
      domain-restart, while with 'variable' the offset is kept. (keeping the
      offset over "virsh edit" is important, since otherwise the clock might
      jump, which confuses certain guest OSs)
      
      xendConfigVersion was last incremented to 4 by the xen-folks for
      xen-3.1.0. I know of no way to reliably detect the version of XenD
      (user space tools), which may be different from the version of the
      hypervisor (kernel) version! Because of this only the change from
      'utc'/'localtime' to 'variable' in XenD-3.1 is handled, not the buggy
      behaviour of XenD-3.1 until XenD-3.4.
      
      For backward compatibility with previous versions of libvirt Xen-HV
      still accepts 'utc' and 'localtime', but they are returned as 'variable'
      on the next read-back from Xend to libvirt, since this is what XenD
      implements: The RTC is NOT reset back to the specified time on next
      restart, but the previous offset is kept.
      This behaviour can be turned off by adding the additional attribute
      adjustment='reset', in which case libvirt will report an error instead
      of doing the conversion. The attribute can also be used as a shortcut to
      offset='variable' with basis='...'.
      
      With these changes, it is also necessary to adjust the xen tests:
      
      "localtime = 0" is always inserted, because otherwise on updates the
      value is not changed within XenD.
      
      adjustment='reset' is inserted for all cases, since they're all <
      XEND_CONFIG_VERSION_3_1_0, only 3.1 introduced persistent
      rtc_timeoffset.
      
      Some statements change their order because code was moved around.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      11ec6bd8
    • P
      Support clock=variable relative to localtime · b8bf79aa
      Philipp Hahn 提交于
      Since Xen 3.1 the clock=variable semantic is supported. In addition to
      qemu/kvm Xen also knows about a variant where the offset is relative to
      'localtime' instead of 'utc'.
      
      Extends the libvirt structure with a flag 'basis' to specify, if the
      offset is relative to 'localtime' or 'utc'.
      
      Extends the libvirt structure with a flag 'reset' to force the reset
      behaviour of 'localtime' and 'utc'; this is needed for backward
      compatibility with previous versions of libvirt, since they report
      incorrect XML.
      
      Adapt the only user 'qemu' to the new name.
      Extend the RelaxNG schema accordingly.
      Document the new 'basis' attribute in the HTML documentation.
      Adapt test for the new attribute.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      b8bf79aa
    • Y
      Fix typos and spacing in messages. · 867ed7bb
      Yuri Chornoivan 提交于
      867ed7bb
    • L
      qemu: fix memory leak in virDomainGetVcpus · a4650316
      Laine Stump 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=808979
      
      The leak is really in virProcessInfoGetAffinity, as shown in the
      valgrind output given in the above bug report - it calls CPU_ALLOC(),
      but then fails to call CPU_FREE().
      
      This leak has existed in every version of libvirt since 0.7.5.
      a4650316