1. 28 4月, 2015 6 次提交
  2. 23 4月, 2015 1 次提交
    • Z
      qemu: move setting emulatorpin ahead of monitor showing up · 91ced385
      Zhou yimin 提交于
      If VM is configured with many devices(including passthrough devices)
      and large memory, libvirtd will take seconds(in the worst case) to
      wait for monitor. In this period the qemu process may run on any
      PCPU though I intend to pin emulator to the specified PCPU in xml
      configuration.
      
      Actually qemu process takes high cpu usage during vm startup.
      So this is not the strict CPU isolation in this case.
      Signed-off-by: NZhou yimin <zhouyimin@huawei.com>
      (cherry picked from commit 411cea63)
      91ced385
  3. 16 4月, 2015 9 次提交
  4. 10 4月, 2015 1 次提交
    • M
      virNetworkDefUpdateIPDHCPHost: Don't crash when updating network · cf2289f2
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1182486
      
      When updating a network and adding new ip-dhcp-host entry, the deamon
      may crash. The problem is, we iterate over existing <host/> entries
      trying to compare MAC addresses to see if there's already an existing
      rule. However, not all entries are required to have MAC address. For
      instance, the following is perfectly valid entry:
      
      <host id='00:04:58:fd:e4:15:1b:09:4c:0e:09:af:e4:d3:8c:b8:ca:1e'
      name='redhatipv6.redhat.com' ip='2001:db8:ca2:2::119'/>
      
      When the checking loop iterates over this, the entry's MAC address is
      accessed directly. Well, the fix is obvious - check if the address is
      defined before trying to compare it.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit 7d3ae359)
      cf2289f2
  5. 17 3月, 2015 1 次提交
    • E
      daemon: avoid memleak when ListAll returns nothing · b9dacdd4
      Eric Blake 提交于
      Commit 4f25146b (v1.2.8) managed to silence Coverity, but at the
      cost of a memory leak detected by valgrind:
      ==24129== 40 bytes in 5 blocks are definitely lost in loss record 355 of 637
      ==24129==    at 0x4A08B1C: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==24129==    by 0x5084B8E: virReallocN (viralloc.c:245)
      ==24129==    by 0x514D5AA: virDomainObjListExport (domain_conf.c:22200)
      ==24129==    by 0x201227DB: qemuConnectListAllDomains (qemu_driver.c:18042)
      ==24129==    by 0x51CC1B6: virConnectListAllDomains (libvirt-domain.c:6797)
      ==24129==    by 0x14173D: remoteDispatchConnectListAllDomains (remote.c:1580)
      ==24129==    by 0x121BE1: remoteDispatchConnectListAllDomainsHelper (remote_dispatch.h:1072)
      
      In short, every time a client calls a ListAll variant and asks
      for the resulting list, but there are 0 elements to return, we
      end up leaking the 1-entry array that holds the NULL terminator.
      
      What's worse, a read-only client can access these functions in a
      tight loop to cause libvirtd to eventually run out of memory; and
      this can be considered a denial of service attack against more
      privileged clients.  Thankfully, the leak is so small (8 bytes per
      call) that you would already have some other denial of service with
      any guest calling the API that frequently, so an out-of-memory
      crash is unlikely enough that this did not warrant a CVE.
      
      * daemon/remote.c (remoteDispatchConnectListAllDomains)
      (remoteDispatchDomainListAllSnapshots)
      (remoteDispatchDomainSnapshotListAllChildren)
      (remoteDispatchConnectListAllStoragePools)
      (remoteDispatchStoragePoolListAllVolumes)
      (remoteDispatchConnectListAllNetworks)
      (remoteDispatchConnectListAllInterfaces)
      (remoteDispatchConnectListAllNodeDevices)
      (remoteDispatchConnectListAllNWFilters)
      (remoteDispatchConnectListAllSecrets)
      (remoteDispatchNetworkGetDHCPLeases): Plug leak.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      (cherry picked from commit 3c2ff502)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      
      Conflicts:
      	daemon/remote.c - context with older cleanup styles
      b9dacdd4
  6. 26 2月, 2015 2 次提交
  7. 14 2月, 2015 1 次提交
  8. 11 2月, 2015 1 次提交
    • Z
      conf: Fix libvirtd crash and memory leak caused by virDomainVcpuPinDel() · 0df83949
      Zhang Bo 提交于
      The function virDomainVcpuPinDel() used vcpupin_list to stand for
      def->cputune.vcpupin, which made the codes more readable.
      However, in this function, it will realloc vcpupin_list later.
      As the definition of realloc(), it may free vcpupin_list and then
      points it to a new-realloced address, but def->cputune.vcpupin doesn't
      point to the new address(it's freed however).
      Thus,
      1) When we refer to the def->cputune.vcpupin afterwards, which was freed
      by realloc(), an INVALID READ occurs, and libvirtd may crash.
      2) As no one will use vcpupin_list any more, and no one frees it(it's just
      alloced by realloc()), memory leak occurs.
      
      Part of the valgrind logs are shown as below:
      ==1837== Thread 15:
      ==1837== Invalid read of size 8
      ==1837==    at 0x5367337: virDomainDefFormatInternal (domain_conf.c:18392)
              which is : virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
                                def->cputune.vcpupin[i]->vcpuid);
      ==1837==    by 0x536966C: virDomainObjFormat (domain_conf.c:18970)
      ==1837==    by 0x5369743: virDomainSaveStatus (domain_conf.c:19166)
      ==1837==    by 0x117B26DC: qemuDomainPinVcpuFlags (qemu_driver.c:4586)
      ==1837==    by 0x53EA313: virDomainPinVcpuFlags (libvirt.c:9803)
      ==1837==    by 0x14CB7D: remoteDispatchDomainPinVcpuFlags (remote_dispatch.h:6762)
      ==1837==    by 0x14CC81: remoteDispatchDomainPinVcpuFlagsHelper (remote_dispatch.h:6740)
      ==1837==    by 0x5464C30: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
      ==1837==    by 0x546507A: virNetServerProgramDispatch (virnetserverprogram.c:307)
      ==1837==    by 0x171B83: virNetServerProcessMsg (virnetserver.c:172)
      ==1837==    by 0x171E6E: virNetServerHandleJob (virnetserver.c:193)
      ==1837==    by 0x5318E78: virThreadPoolWorker (virthreadpool.c:145)
      ==1837==  Address 0x12ea2870 is 0 bytes inside a block of size 16 free'd
      ==1837==    at 0x4C291AC: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==1837==    by 0x52A3D14: virReallocN (viralloc.c:245)
      ==1837==    by 0x52A3DFB: virShrinkN (viralloc.c:372)
      ==1837==    by 0x52A3F57: virDeleteElementsN (viralloc.c:503)
      ==1837==    by 0x533939E: virDomainVcpuPinDel (domain_conf.c:15405)  //doReset为true时才会进到。
      ==1837==    by 0x117B2642: qemuDomainPinVcpuFlags (qemu_driver.c:4573)
      ==1837==    by 0x53EA313: virDomainPinVcpuFlags (libvirt.c:9803)
      ==1837==    by 0x14CB7D: remoteDispatchDomainPinVcpuFlags (remote_dispatch.h:6762)
      ==1837==    by 0x14CC81: remoteDispatchDomainPinVcpuFlagsHelper (remote_dispatch.h:6740)
      ==1837==    by 0x5464C30: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
      ==1837==    by 0x546507A: virNetServerProgramDispatch (virnetserverprogram.c:307)
      ==1837==    by 0x171B83: virNetServerProcessMsg (virnetserver.c:172)
      
      Steps to reproduce the problem:
      1) use virDomainPinVcpuFlags() to pin a guest's vcpu to all the pcpus
      of the host.
      
      This patch uses def->cputune.vcpupin instead of vcpupin_list to do the
      realloc() job, to avoid invalid read or memory leaking.
      Signed-off-by: NZhang Bo <oscar.zhangbo@huawei.com>
      Signed-off-by: Yue Wenyuan <yuewenyuan@huawei.com@huawei.com>
      (cherry picked from commit 2d27dcb0)
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      0df83949
  9. 08 2月, 2015 3 次提交
    • C
      Prep for release 1.2.9.2 · 2ed8e729
      Cole Robinson 提交于
      2ed8e729
    • P
      util: storage: Fix parsing of nbd:// URI without path · f6dd410d
      Peter Krempa 提交于
      If a storage file would be backed with a NBD device without path
      (nbd://localhost) libvirt would crash when parsing the backing path for
      the disk as the URI structure's path element is NULL in such case but
      the NBD parser would access it shamelessly.
      
      (cherry picked from commit fdb80ed4)
      f6dd410d
    • W
      qemu: fix domain startup failing with 'strict' mode in numatune · e2267726
      Wang Rui 提交于
      If the memory mode is specified as 'strict' and with one node, we
      get the following error when starting domain.
      
      error: Unable to write to '$cgroup_path/cpuset.mems': Device or resource busy
      
      XML is configured with numatune as follows:
        <numatune>
          <memory mode='strict' nodeset='0'/>
        </numatune>
      
      It's broken by Commit 411cea63
      which moved qemuSetupCgroupForEmulator() before setting cpuset.mems
      in qemuSetupCgroupPostInit.
      
      Directory '$cgroup_path/emulator/' is created in qemuSetupCgroupForEmulator.
      But '$cgroup_path/emulator/cpuset.mems' it not set and has a default value
      (all nodes, such as 0-1). Then we setup '$cgroup_path/cpuset.mems' to the
      nodemask (in this case it's '0') in qemuSetupCgroupPostInit. It must fail.
      
      This patch makes '$cgroup_path/emulator/cpuset.mems' is set before
      '$cgroup_path/cpuset.mems'. The action is similar with that in
      qemuDomainSetNumaParamsLive.
      Signed-off-by: NWang Rui <moon.wangrui@huawei.com>
      (cherry picked from commit c6e90248)
      e2267726
  10. 02 2月, 2015 1 次提交
    • J
      storage: Need to clear pool prior to refreshPool during Autostart · ca1701e3
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1176510
      
      When storageDriverAutostart is called path virStateReload via a 'service
      libvirtd reload', then because the volume list in the pool wasn't cleared
      prior to the call, each volume would be listed multiple times (as many
      times as we reload). I believe the issue would be introduced by commit
      id '9e093f0b' at least for the libvirtd reload path, although I suppose
      the introduction of virStateReload (commit id '70da0494') could be a
      different cause.
      
      Thus like other places prior to calling refreshPool, we need to call
      virStoragePoolObjClearVols
      
      (cherry picked from commit 1d2e4d8c)
      ca1701e3
  11. 30 1月, 2015 1 次提交
    • M
      xend: Don't crash in virDomainXMLDevID · 2c8a5b5e
      Michal Privoznik 提交于
      The function is called from all {Attach,Update,Detach}Device APIs to
      create config strings that are later passed to the xend to perform the
      desired action. The function is intended to handle all supported
      devices. However, as of 5b05358a we
      are trying to get disk driver of the device without checking if the
      device really is a disk. This leads to an segmentation fault:
      
        #0 0x00007ffff7571815 in virDomainDiskGetDriver () from /usr/lib/libvirt.so.0
        #1 0x00007fffeb9ad471 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
        #2 0x00007fffeb9b1062 in xenDaemonAttachDeviceFlags () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
        #3 0x00007fffeb9a8a86 in ?? () from /usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
        #4 0x00007ffff7609266 in virDomainAttachDevice () from /usr/lib/libvirt.so.0
        #5 0x0000555555593c9d in ?? ()
        #6 0x00007ffff76743c9 in virNetServerProgramDispatch () from /usr/lib/libvirt.so.0
        #7 0x00005555555a678d in ?? ()
        #8 0x00007ffff755460e in ?? () from /usr/lib/libvirt.so.0
        #9 0x00007ffff7553b06 in ?? () from /usr/lib/libvirt.so.0
        #10 0x00007ffff4998b50 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
        #11 0x00007ffff46e30ed in clone () from /lib/x86_64-linux-gnu/libc.so.6
        #12 0x0000000000000000 in ?? ()
      Reported-by: NXiaolin Su <linxxnil@126.com>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit cd7702d4)
      2c8a5b5e
  12. 23 1月, 2015 2 次提交
  13. 22 1月, 2015 3 次提交
  14. 23 12月, 2014 2 次提交
    • P
      qemu: migration: Unlock vm on failed ACL check in protocol v2 APIs · 12496319
      Peter Krempa 提交于
      Avoid leaving the domain locked on a failed ACL check in
      qemuDomainMigratePerform() and qemuDomainMigrateFinish2().
      
      Introduced in commit abf75aea (Add ACL checks into the QEMU driver).
      
      (cherry picked from commit 2bdcd29c)
      12496319
    • L
      storage: fix crash caused by no check return before set close · 584e876b
      Luyao Huang 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1087104#c5
      
      When trying to use an invalid offset to virStorageVolUpload(), libvirt
      fails in virFDStreamOpenFileInternal(), although it seems libvirt does
      not check the return in storageVolUpload(), and calls
      virFDStreamSetInternalCloseCb() right after.  But stream doesn't have a
      privateData (is NULL) yet, and the daemon crashes then.
      
      0  0x00007f09429a9c10 in pthread_mutex_lock () from /lib64/libpthread.so.0
      1  0x00007f094514dbf5 in virMutexLock (m=<optimized out>) at util/virthread.c:88
      2  0x00007f09451cb211 in virFDStreamSetInternalCloseCb at fdstream.c:795
      3  0x00007f092ff2c9eb in storageVolUpload at storage/storage_driver.c:2098
      4  0x00007f09451f46e0 in virStorageVolUpload at libvirt.c:14000
      5  0x00007f0945c78fa1 in remoteDispatchStorageVolUpload at remote_dispatch.h:14339
      6  remoteDispatchStorageVolUploadHelper at remote_dispatch.h:14309
      7  0x00007f094524a192 in virNetServerProgramDispatchCall at rpc/virnetserverprogram.c:437
      Signed-off-by: NLuyao Huang <lhuang@redhat.com>
      (cherry picked from commit 87b9437f)
      584e876b
  15. 11 12月, 2014 1 次提交
  16. 10 12月, 2014 1 次提交
    • M
      CVE-2014-8131: Fix possible deadlock and segfault in qemuConnectGetAllDomainStats() · 5d8bee6d
      Martin Kletzander 提交于
      When user doesn't have read access on one of the domains he requested,
      the for loop could exit abruptly or continue and override pointer which
      pointed to locked object.
      
      This patch fixed two issues at once.  One is that domflags might have
      had QEMU_DOMAIN_STATS_HAVE_JOB even when there was no job started (this
      is fixed by doing domflags |= QEMU_DOMAIN_STATS_HAVE_JOB only when the
      job was acquired and cleaning domflags on every start of the loop.
      Second one is that the domain is kept locked when
      virConnectGetAllDomainStatsCheckACL() fails and continues the loop when
      it didn't end.  Adding a simple virObjectUnlock() and clearing the
      pointer ought to do.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit 57023c0a)
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      5d8bee6d
  17. 03 12月, 2014 2 次提交
  18. 16 11月, 2014 2 次提交