1. 08 11月, 2013 6 次提交
    • P
      cpu: x86: Add internal CPUID features support and KVM feature bits · 2e8f9080
      Peter Krempa 提交于
      Some of the emulator features are presented in the <features> element in
      the domain XML although they are virtual CPUID feature bits when
      presented to the guest. To avoid confusing the users with these
      features, as they are not configurable via the <cpu> element, this patch
      adds an internal array where those can be stored privately instead of
      exposing them in the XML.
      
      Additionaly KVM feature bits are added as example usage of this code.
      2e8f9080
    • J
      qemu: Add monitor APIs to fetch CPUID data from QEMU · 3afde075
      Jiri Denemark 提交于
      The qemu monitor supports retrieval of actual CPUID bits presented to
      the guest using QMP monitor. Add APIs to extract these information and
      tests for them.
      Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
      3afde075
    • P
      cpu_x86: Refactor storage of CPUID data to add support for KVM features · f80a11c9
      Peter Krempa 提交于
      The CPUID functions were stored in multiple arrays according to a
      specified prefix of those. This made it very hard to add another prefix
      to store KVM CPUID features (0x40000000). Instead of hardcoding a third
      array this patch changes the approach used:
      
      The code is refactored to use a single array where the CPUID functions
      are stored ordered by the cpuid function so that they don't depend on
      the specific prefix and don't waste memory. The code is also less
      complex using this approach. A trateoff to this is the change from O(N)
      complexity to O(N^2) in x86DataAdd and x86DataSubtract. The rest of the
      functions were already using O(N^2) algorithms.
      f80a11c9
    • L
      storage: Fix a vol-clone bug on ppc64 · 4ffcb020
      Li Zhang 提交于
      vol-clone reports out of memory error with disk type on ppc64.
      
      Currently, wbytes is defined as size_t type (8 bytes), but
      args's value in ioctl(fd, args..) in kernel is int (4 bytes).
      This makes wbytes 2^32 times larger, causing an out of memory error.
      
      This patch changes size_t to int to synchronize with kernel.
      
      [1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/block/ioctl.c?id=5e01dc7b#n363
      [2] https://lkml.org/lkml/2013/11/1/620Signed-off-by: NLi Zhang <zhlcindy@linux.vnet.ibm.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      4ffcb020
    • M
      qemu: Don't access vm->priv on unlocked domain · 1f2f879e
      Michal Privoznik 提交于
      Since 86d90b3a (yes, my patch; again) we are supporting NBD storage
      migration. However, on error recovery path we got the steps reversed.
      The correct order is: return NBD port to the virPortAllocator and then
      either unlock the vm or remove it from the driver. Not vice versa.
      
      ==11192== Invalid write of size 4
      ==11192==    at 0x11488559: qemuMigrationPrepareAny (qemu_migration.c:2459)
      ==11192==    by 0x11488EA6: qemuMigrationPrepareDirect (qemu_migration.c:2652)
      ==11192==    by 0x114D1509: qemuDomainMigratePrepare3Params (qemu_driver.c:10332)
      ==11192==    by 0x519075D: virDomainMigratePrepare3Params (libvirt.c:7290)
      ==11192==    by 0x1502DA: remoteDispatchDomainMigratePrepare3Params (remote.c:4798)
      ==11192==    by 0x12DECA: remoteDispatchDomainMigratePrepare3ParamsHelper (remote_dispatch.h:5741)
      ==11192==    by 0x5212127: virNetServerProgramDispatchCall (virnetserverprogram.c:435)
      ==11192==    by 0x5211C86: virNetServerProgramDispatch (virnetserverprogram.c:305)
      ==11192==    by 0x520A8FD: virNetServerProcessMsg (virnetserver.c:165)
      ==11192==    by 0x520A9E1: virNetServerHandleJob (virnetserver.c:186)
      ==11192==    by 0x50DA78F: virThreadPoolWorker (virthreadpool.c:144)
      ==11192==    by 0x50DA11C: virThreadHelper (virthreadpthread.c:161)
      ==11192==  Address 0x1368baa0 is 576 bytes inside a block of size 688 free'd
      ==11192==    at 0x4A07F5C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==11192==    by 0x5079A2F: virFree (viralloc.c:580)
      ==11192==    by 0x11456C34: qemuDomainObjPrivateFree (qemu_domain.c:267)
      ==11192==    by 0x50F41B4: virDomainObjDispose (domain_conf.c:2034)
      ==11192==    by 0x50C2991: virObjectUnref (virobject.c:262)
      ==11192==    by 0x50F4CFC: virDomainObjListRemove (domain_conf.c:2361)
      ==11192==    by 0x1145C125: qemuDomainRemoveInactive (qemu_domain.c:2087)
      ==11192==    by 0x11488520: qemuMigrationPrepareAny (qemu_migration.c:2456)
      ==11192==    by 0x11488EA6: qemuMigrationPrepareDirect (qemu_migration.c:2652)
      ==11192==    by 0x114D1509: qemuDomainMigratePrepare3Params (qemu_driver.c:10332)
      ==11192==    by 0x519075D: virDomainMigratePrepare3Params (libvirt.c:7290)
      ==11192==    by 0x1502DA: remoteDispatchDomainMigratePrepare3Params (remote.c:4798)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      1f2f879e
    • M
      qemu: Avoid double free of VM · 5a4c2374
      Michal Privoznik 提交于
      One of my previous patches (c7ac2519) did try to fix the issue when
      domain dies too soon during migration. However, this clumsy approach was
      missing removal of qemuProcessHandleMonitorDestroy resulting in double
      unrefing of mon->vm and hence producing the daemon crash:
      
      ==11843== Invalid read of size 4
      ==11843==    at 0x50C28C5: virObjectUnref (virobject.c:255)
      ==11843==    by 0x1148F7DB: qemuMonitorDispose (qemu_monitor.c:258)
      ==11843==    by 0x50C2991: virObjectUnref (virobject.c:262)
      ==11843==    by 0x50C2D13: virObjectFreeCallback (virobject.c:388)
      ==11843==    by 0x509C37B: virEventPollCleanupHandles (vireventpoll.c:583)
      ==11843==    by 0x509C711: virEventPollRunOnce (vireventpoll.c:652)
      ==11843==    by 0x509A620: virEventRunDefaultImpl (virevent.c:274)
      ==11843==    by 0x520D21C: virNetServerRun (virnetserver.c:1112)
      ==11843==    by 0x11F368: main (libvirtd.c:1513)
      ==11843==  Address 0x13b88864 is 4 bytes inside a block of size 136 free'd
      ==11843==    at 0x4A07F5C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==11843==    by 0x5079A2F: virFree (viralloc.c:580)
      ==11843==    by 0x50C29E3: virObjectUnref (virobject.c:270)
      ==11843==    by 0x114770E4: qemuProcessHandleMonitorDestroy (qemu_process.c:1103)
      ==11843==    by 0x1148F7CB: qemuMonitorDispose (qemu_monitor.c:257)
      ==11843==    by 0x50C2991: virObjectUnref (virobject.c:262)
      ==11843==    by 0x50C2D13: virObjectFreeCallback (virobject.c:388)
      ==11843==    by 0x509C37B: virEventPollCleanupHandles (vireventpoll.c:583)
      ==11843==    by 0x509C711: virEventPollRunOnce (vireventpoll.c:652)
      ==11843==    by 0x509A620: virEventRunDefaultImpl (virevent.c:274)
      ==11843==    by 0x520D21C: virNetServerRun (virnetserver.c:1112)
      ==11843==    by 0x11F368: main (libvirtd.c:1513)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      5a4c2374
  2. 07 11月, 2013 11 次提交
    • M
      qemuMigrationBeginPhase: Check for 'drive-mirror' for NBD · b2f31af7
      Michal Privoznik 提交于
      So far we are checking if qemu supports 'nbd-server-start'. This,
      however, makes no sense on the source as nbd-server-* is used on the
      destination. On the source the 'drive-mirror' is used instead.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      b2f31af7
    • C
      conf: fix incorrect error log in virCPUDefIsEqual · 4bcb74d0
      Chen Hanxiao 提交于
      A copy-paste error.
      s/model/vendor id
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      4bcb74d0
    • P
      conf: Refactor virDomainDiskSourcePoolDefParse · 6e037015
      Peter Krempa 提交于
      For some strange reason virDomainDiskSourcePoolDefParse accessed def of
      the disk and allocated the pool object in it. To avoid the need to carry
      over the disk definition object, refactor this function to return the
      allocated object instead.
      6e037015
    • E
      nodeinfo: fix build on non-Linux · adb44955
      Eric Blake 提交于
      Commit b0f85462 broke the build on mingw, by exposing code that
      had Linux-specific dependencies but which was previously protected
      by libnuma ifdef guards:
      
      make[3]: Entering directory `/home/eblake/libvirt-tmp/build/src'
        CC       libvirt_driver_la-nodeinfo.lo
      ../../src/nodeinfo.c: In function 'virNodeGetSiblingsList':
      ../../src/nodeinfo.c:1543:30: error: 'SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX' undeclared (first use in this function)
           if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
                                    ^
      ../../src/nodeinfo.c:1543:30: note: each undeclared identifier is reported only once for each function it appears in
      ../../src/nodeinfo.c: In function 'virNodeCapsFillCPUInfo':
      ../../src/nodeinfo.c:1562:5: error: implicit declaration of function 'virNodeGetCpuValue' [-Werror=implicit-function-declaration]
           if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id,
           ^
      ../../src/nodeinfo.c:1562:5: error: nested extern declaration of 'virNodeGetCpuValue' [-Werror=nested-externs]
      ../../src/nodeinfo.c:1562:35: error: 'SYSFS_CPU_PATH' undeclared (first use in this function)
           if ((tmp = virNodeGetCpuValue(SYSFS_CPU_PATH, cpu_id,
                                         ^
      cc1: all warnings being treated as errors
      
      * src/nodeinfo.c (virNodeCapsFillCPUInfo): Make conditional.
      (virNodeGetSiblingsList): Move into #ifdef linux block.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      adb44955
    • E
      storage: always probe type with buffer · 348b4e25
      Eric Blake 提交于
      This gets rid of another stat() per volume, as well as cutting
      bytes read in half, when populating the volumes of a directory
      pool during a pool refresh.  Not to mention that it provides an
      interface that can let gluster pools also probe file types.
      
      * src/util/virstoragefile.h (virStorageFileProbeFormatFromFD):
      Delete.
      (virStorageFileProbeFormatFromBuf): New prototype.
      (VIR_STORAGE_MAX_HEADER): New constant, based on...
      * src/util/virstoragefile.c (STORAGE_MAX_HEAD): ...old name.
      (vmdk4GetBackingStore, virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormat): Adjust clients.
      (virStorageFileProbeFormatFromFD): Delete.
      (virStorageFileProbeFormatFromBuf): Export.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Adjust client.
      * src/libvirt_private.syms (virstoragefile.h): Adjust exports.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      348b4e25
    • E
      storage: refactor backing chain division of labor · 3ead2e7d
      Eric Blake 提交于
      Future patches will want to learn metadata about a file using
      a buffer that was already parsed in order to probe the file's
      format.  Rather than reopening and re-reading the file, it makes
      sense to separate getting file contents from actually parsing
      those contents.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf)
      (virStorageFileGetMetadataFromFDInternal): New functions.
      (virStorageFileGetMetadataInternal): Hoist fstat() and read() into
      callers.
      (virStorageFileGetMetadataFromFD)
      (virStorageFileGetMetadataRecurse): Rework clients.
      * src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
      New prototype.
      * src/libvirt_private.syms (virstoragefile.h): Export it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      3ead2e7d
    • E
      storage: reduce number of stat calls · 9cac8639
      Eric Blake 提交于
      We are calling fstat() at least twice per storage volume in
      a directory storage pool; this is rather wasteful.  Refactoring
      this is also a step towards making code reusable for gluster,
      where gluster can provide struct stat but cannot use fstat().
      
      * src/storage/storage_backend.h
      (virStorageBackendVolOpenCheckMode)
      (virStorageBackendUpdateVolTargetInfoFD): Update signature.
      * src/storage/storage_backend.c
      (virStorageBackendVolOpenCheckMode): Pass stat results back.
      (virStorageBackendUpdateVolTargetInfoFD): Use existing stats.
      (virStorageBackendVolOpen, virStorageBackendUpdateVolTargetInfo):
      Update callers.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Likewise.
      * src/storage/storage_backend_scsi.c
      (virStorageBackendSCSIUpdateVolTargetInfo): Likewise.
      * src/storage/storage_backend_mpath.c
      (virStorageBackendMpathUpdateVolTargetInfo): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      9cac8639
    • E
      storage: avoid short reads while chasing backing chain · 5327fad4
      Eric Blake 提交于
      Our backing file chain code was not very robust to an ill-timed
      EINTR, which could lead to a short read causing us to randomly
      treat metadata differently than usual.  But the existing
      virFileReadLimFD forces an error if we don't read the entire
      file, even though we only care about the header of the file.
      So add a new virFile function that does what we want.
      
      * src/util/virfile.h (virFileReadHeaderFD): New prototype.
      * src/util/virfile.c (virFileReadHeaderFD): New function.
      * src/libvirt_private.syms (virfile.h): Export it.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5327fad4
    • E
      storage: use simpler 'char *' · 5717ee6a
      Eric Blake 提交于
      'unsigned char *' makes sense if you are doing math on bytes and
      don't want to worry about wraparound from a signed 'char'; but
      since all we are doing is memcmp() or virReadBufInt*[LB]E(), which
      are both safe on either type of char, and since read() prefers to
      operate on 'char *', it's simpler to avoid casts by just typing
      things as 'char *' from the get-go.  [Technically, read can
      operate on an 'unsigned char *' thanks to the C rule that any
      pointer can be implicitly converted to 'char *' for legacy K&R
      compatibility; but where this patch saves us is if we try to use
      virfile.h functions that take 'char **' in order to allocate the
      buffer, where the compiler would barf on type mismatch.]
      
      * src/util/virstoragefile.c (FileTypeInfo): Avoid unsigned char.
      (cowGetBackingStore, qcow2GetBackingStoreFormat)
      (qcowXGetBackingStore, qcow1GetBackingStore)
      (qcow2GetBackingStore, vmdk4GetBackingStore, qedGetBackingStore)
      (virStorageFileMatchesMagic, virStorageFileMatchesVersion)
      (virStorageFileProbeFormatFromBuf, qcow2GetFeatures)
      (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Simplify clients.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5717ee6a
    • G
      test driver: add support for .connectBaselineCPU · 2b68ad71
      Giuseppe Scrivano 提交于
      It uses the same functionalities of the qemu driver.
      Signed-off-by: NGiuseppe Scrivano <gscrivan@redhat.com>
      2b68ad71
    • M
      qemuMonitorDispose: Reset lastError · 9cc8a5af
      Michal Privoznik 提交于
      Since the 90139a62 commit the error is copied into mon->lastError but
      it's never freed from there.
      
      ==31989== 395 bytes in 1 blocks are definitely lost in loss record 877 of 978
      ==31989==    at 0x4A06C2B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==31989==    by 0x7EAF129: strdup (in /lib64/libc-2.15.so)
      ==31989==    by 0x50D586C: virStrdup (virstring.c:554)
      ==31989==    by 0x50976C1: virCopyError (virerror.c:191)
      ==31989==    by 0x5097A35: virCopyLastError (virerror.c:312)
      ==31989==    by 0x114909A9: qemuMonitorIO (qemu_monitor.c:690)
      ==31989==    by 0x509BEDE: virEventPollDispatchHandles (vireventpoll.c:501)
      ==31989==    by 0x509C701: virEventPollRunOnce (vireventpoll.c:648)
      ==31989==    by 0x509A620: virEventRunDefaultImpl (virevent.c:274)
      ==31989==    by 0x520D21C: virNetServerRun (virnetserver.c:1112)
      ==31989==    by 0x11F368: main (libvirtd.c:1513)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      9cc8a5af
  3. 06 11月, 2013 3 次提交
    • Z
      qemu: clean up migration ports when migration cancelled · c92ca769
      Zeng Junliang 提交于
      If there's a migration cancelled, the bitmap of migration port should be
      cleaned up too.
      Signed-off-by: NZeng Junliang <zengjunliang@huawei.com>
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      c92ca769
    • L
      network: fix connections count in case of allocate failure · b4e0299d
      Laine Stump 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1020135
      
      If networkAllocateActualDevice() had failed due to a pool of hostdev
      or direct devices being depleted, the calling function could still
      call networkReleaseActualDevice() as part of its cleanup, and that
      function would then unconditionally decrement the connections count
      for the network, even though it hadn't been incremented (due to
      failure of allocate). This *was* necessary because the .actual member
      of the netdef was allocated with a "lazy" algorithm, only being
      created if there was a need to store data there (e.g. if a device was
      allocated from a pool, or bandwidth was allocated for the device), so
      there was no simple way for networkReleaseActualDevice() to tell if
      something really had been allocated (i.e. if "connections++" had been
      executed).
      
      This patch changes networkAllocateDevice() to *always* allocate an
      actual device for any netdef of type='network', even if it isn't
      needed for any other reason. This has no ill effects anywhere else in
      the code (except for using a small amount of memory), and
      networkReleaseActualDevice() can then determine if there was a
      previous successful allocate by checking for .actual != NULL (if not,
      it skips the "connections--").
      b4e0299d
    • G
      virt-login-shell: also build virAtomic.h · 12dc729a
      Guido Günther 提交于
      Needed for architectures that don't use gcc atomic ops but pthread. This
      fixes the armel build that otherwise breaks like:
      
       CCLD     virt-login-shell
       ../src/.libs/libvirt-setuid-rpc-client.a(libvirt_setuid_rpc_client_la-virobject.o): In function `virClassNew':
       /«PKGBUILDDIR»/debian/build/src/../../../src/util/virobject.c:150: undefined reference to `virAtomicLock'
       ../src/.libs/libvirt-setuid-rpc-client.a(libvirt_setuid_rpc_client_la-virobject.o): In function `virObjectNew':
       /«PKGBUILDDIR»/debian/build/src/../../../src/util/virobject.c:202: undefined reference to `virAtomicLock'
       ../src/.libs/libvirt-setuid-rpc-client.a(libvirt_setuid_rpc_client_la-virobject.o): In function `virObjectUnref':
       /«PKGBUILDDIR»/debian/build/src/../../../src/util/virobject.c:274: undefined reference to `virAtomicLock'
       ../src/.libs/libvirt-setuid-rpc-client.a(libvirt_setuid_rpc_client_la-virobject.o): In function `virObjectRef':
       /«PKGBUILDDIR»/debian/build/src/../../../src/util/virobject.c:295: undefined reference to `virAtomicLock'
       collect2: error: ld returned 1 exit status
      
      See https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=armel&ver=1.1.4-1&stamp=1383588268
      12dc729a
  4. 05 11月, 2013 10 次提交
  5. 04 11月, 2013 10 次提交