1. 11 5月, 2017 40 次提交
    • P
      qemu: process: Clean up priv->migTLSAlias · b4b88049
      Peter Krempa 提交于
      The alias would be leaked, since it's not freed on the vm stop path.
      
      (cherry picked from commit 8c1fee5f)
      b4b88049
    • P
      qemu: process: Don't leak priv->usbaddrs after VM restart · 849fbcf7
      Peter Krempa 提交于
      Since the private data structure is not freed upon stopping a VM, the
      usbaddrs pointer would be leaked:
      
      ==15388== 136 (16 direct, 120 indirect) bytes in 1 blocks are definitely lost in loss record 893 of 1,019
      ==15388==    at 0x4C2CF55: calloc (vg_replace_malloc.c:711)
      ==15388==    by 0x54BF64A: virAlloc (viralloc.c:144)
      ==15388==    by 0x5547588: virDomainUSBAddressSetCreate (domain_addr.c:1608)
      ==15388==    by 0x144D38A2: qemuDomainAssignUSBAddresses (qemu_domain_address.c:2458)
      ==15388==    by 0x144D38A2: qemuDomainAssignAddresses (qemu_domain_address.c:2515)
      ==15388==    by 0x144ED1E3: qemuProcessPrepareDomain (qemu_process.c:5398)
      ==15388==    by 0x144F51FF: qemuProcessStart (qemu_process.c:5979)
      [...]
      
      (cherry picked from commit 3ab802d6)
      849fbcf7
    • P
      qemu: process: Clean automatic NUMA/cpu pinning information on shutdown · 0b99253a
      Peter Krempa 提交于
      Clean the stale data after shutting down the VM. Otherwise the data
      would be leaked on next VM start. This happens due to the fact that the
      private data object is not freed on destroy of the VM.
      
      (cherry picked from commit 1730cdc6)
      0b99253a
    • E
      qemu: Remove extra messages for vhost-scsi hotplug · 26dc51ef
      Eric Farman 提交于
      As with virtio-scsi, the "internal error" messages after
      preparing a vhost-scsi hostdev overwrites more meaningful
      error messages deeper in the callchain.  Remove it too.
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      (cherry picked from commit 6ff38cee)
      26dc51ef
    • E
      qemu: Remove extra messages from virtio-scsi hotplug · 6f0ffd8b
      Eric Farman 提交于
      I tried to attach a SCSI LUN to two different guests, and forgot
      to specify "shareable" in the hostdev XML.  Attaching the device
      to the second guest failed, but the message was not helpful in
      telling me what I was doing wrong:
      
        $ cat scsi_scratch_disk.xml
          <hostdev mode='subsystem' type='scsi'>
            <source>
              <adapter name='scsi_host3'/>
              <address bus='0' target='15' unit='1074151456'/>
            </source>
          </hostdev>
      
        $ virsh attach-device dasd_sles_d99c scsi_scratch_disk.xml
        Device attached successfully
      
        $ virsh attach-device dasd_fedora_0e1e scsi_scratch_disk.xml
        error: Failed to attach device from scsi_scratch_disk.xml
        error: internal error: Unable to prepare scsi hostdev: scsi_host3:0:15:1074151456
      
      I eventually discovered my error, but thought it was weird that
      Libvirt doesn't provide something more helpful in this case.
      Looking over the code we had just gone through, I commented out
      the "internal error" message, and got something more useful:
      
        $ virsh attach-device dasd_fedora_0e1e scsi_scratch_disk.xml
        error: Failed to attach device from scsi_scratch_disk.xml
        error: Requested operation is not valid: SCSI device 3:0:15:1074151456 is already in use by other domain(s) as 'non-shareable'
      
      Looking over the error paths here, we seem to issue better
      messages deeper in the callchain so these "internal error"
      messages overwrite any of them.  Remove them, so that the
      more detailed errors are seen.
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      (cherry picked from commit 33c1fc43)
      6f0ffd8b
    • E
      qemu: Check return code from qemuHostdevPrepareSCSIDevices · efadc40f
      Eric Farman 提交于
      Signed-off-by: NEric Farman <farman@linux.vnet.ibm.com>
      (cherry picked from commit 2dc94c3c)
      efadc40f
    • P
      qemu: numa: Don't return automatic nodeset for inactive domain · 796d0c12
      Peter Krempa 提交于
      qemuDomainGetNumaParameters would return the automatic nodeset even for
      the persistent config if the domain was running. This is incorrect since
      the automatic nodeset will be re-queried upon starting the vm.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1445325
      (cherry picked from commit 135c56e2)
      796d0c12
    • J
      qemu: Ignore missing query-migrate-parameters · 13bc6424
      Jiri Denemark 提交于
      Migration with old QEMU which does not support query-migrate-parameters
      would fail because the QMP command is called unconditionally since the
      introduction of TLS migration. Previously it was only called if the user
      explicitly requested a feature which uses QEMU migration parameters. And
      even then the situation was not ideal, instead of reporting an
      unsupported feature we'd just complain about missing QMP command.
      
      Trivially no migration parameters are supported when
      query-migrate-parameters QMP command is missing. There's no need to
      report an error if it is missing, the callers will report better error
      if needed.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1441934Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      (cherry picked from commit ac58c036)
      13bc6424
    • W
      daemon: Fix domain name leak in error path · 7893cc87
      Wang King 提交于
      Domain name is duplicated in make_nonnull_domain, but not freed when
      virTypedParamsSerialize returns error.
      
      (cherry picked from commit f6934047)
      7893cc87
    • Z
      qemu: fix argument of virDomainNetGetActualDirectMode · 2222624d
      ZhiPeng Lu 提交于
      it should be a comparison of modes between new and old devices. So
      the argument of the second virDomainNetGetActualDirectMode should be
      newdev.
      Signed-off-by: NZhiPeng Lu <lu.zhipeng@zte.com.cn>
      (cherry picked from commit c77bc47f)
      2222624d
    • Y
      rpc: fix keep alive timer segfault · db414771
      Yi Wang 提交于
      ka maybe have been freeed in virObjectUnref, application using
      virKeepAliveTimer will segfault when unlock ka. We should keep
      ka's refs positive before using it.
      
      #0  0x00007fd8f79970e8 in virClassIsDerivedFrom (klass=0xdeadbeef, parent=0x7fd8e8001b80) at util/virobject.c:169
      #1  0x00007fd8f799742e in virObjectIsClass (anyobj=anyobj entry=0x7fd8e800b9c0, klass=<optimized out>) at util/virobject.c:365
      #2  0x00007fd8f79974e4 in virObjectUnlock (anyobj=0x7fd8e800b9c0) at util/virobject.c:338
      #3  0x00007fd8f7ac477e in virKeepAliveTimer (timer=<optimized out>, opaque=0x7fd8e800b9c0) at rpc/virkeepalive.c:177
      #4  0x00007fd8f7e5c9cf in libvirt_virEventInvokeTimeoutCallback () from /usr/lib64/python2.7/site-packages/libvirtmod.so
      #5  0x00007fd8ff64db94 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
      #6  0x00007fd8ff64f1ad in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
      #7  0x00007fd8ff64d85f in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
      #8  0x00007fd8ff64d950 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
      #9  0x00007fd8ff64d950 in PyEval_EvalFrameEx () from /lib64/libpython2.7.so.1.0
      #10 0x00007fd8ff64f1ad in PyEval_EvalCodeEx () from /lib64/libpython2.7.so.1.0
      #11 0x00007fd8ff5dc098 in function_call () from /lib64/libpython2.7.so.1.0
      #12 0x00007fd8ff5b7073 in PyObject_Call () from /lib64/libpython2.7.so.1.0
      #13 0x00007fd8ff5c6085 in instancemethod_call () from /lib64/libpython2.7.so.1.0
      #14 0x00007fd8ff5b7073 in PyObject_Call () from /lib64/libpython2.7.so.1.0
      #15 0x00007fd8ff648ff7 in PyEval_CallObjectWithKeywords () from /lib64/libpython2.7.so.1.0
      #16 0x00007fd8ff67d7e2 in t_bootstrap () from /lib64/libpython2.7.so.1.0
      #17 0x00007fd8ff358df3 in start_thread () from /lib64/libpthread.so.0
      #18 0x00007fd8fe97d3ed in clone () from /lib64/libc.so.6
      Signed-off-by: NYi Wang <wang.yi59@zte.com.cn>
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      (cherry picked from commit ab5bb6f3)
      db414771
    • L
      util: allow ignoring SIOCSIFHWADDR when errno is EPERM · e1cb5f79
      Laine Stump 提交于
      Commit f4ef3a71 made a variation of virNetDevSetMAC that would return
      without logging an error message if errno was set to
      EADDRNOTAVAIL. This errno is set by some SRIOV VF drivers (in
      particular igbvf) when they fail to set the device's MAC address due
      to the PF driver refusing the request. This is useful if we want to
      try a different method of setting the VF MAC address before giving up
      (Commit 86556e16 actually does this, setting the desired MAC address
      to the "admin MAC in the PF, then detaching and reattaching the VF
      netdev driver to force a reinit of the MAC address).
      
      During testing of Bug 1442040 t was discovered that the ixgbe driver
      returns EPERM in this situation, so this patch changes the exception
      case for silent+non-terminal failure to account for this difference.
      
      Completes resolution to: https://bugzilla.redhat.com/1415609 (RHEL 7.4)
                               https://bugzilla.redhat.com/1442040 (RHEL 7.3.z)
      
      (cherry picked from commit 997134fb)
      e1cb5f79
    • P
      util: check ifa_addr pointer before accessing its elements · 2679eeea
      Pavel Hrdina 提交于
      Reported by Rafał Wojciechowski <it@rafalwojciechowski.pl>.
      
      Thread 1 (Thread 0x7f194b99d700 (LWP 5631)):
      0  virNetDevGetifaddrsAddress (addr=0x7f194b99c7c0, ifname=0x7f193400e2b0 "ovirtmgmt") at util/virnetdevip.c:738
      1  virNetDevIPAddrGet (ifname=0x7f193400e2b0 "ovirtmgmt", addr=addr@entry=0x7f194b99c7c0) at util/virnetdevip.c:795
      2  0x00007f19467800d6 in networkGetNetworkAddress (netname=<optimized out>, netaddr=netaddr@entry=0x7f1924013f18) at network/bridge_driver.c:4780
      3  0x00007f193e43a33c in qemuProcessGraphicsSetupNetworkAddress (listenAddr=0x7f19340f7650 "127.0.0.1", glisten=0x7f1924013f10) at qemu/qemu_process.c:4062
      4  qemuProcessGraphicsSetupListen (vm=<optimized out>, graphics=0x7f1924014f10, cfg=0x7f1934119f00) at qemu/qemu_process.c:4133
      5  qemuProcessSetupGraphics (flags=17, vm=0x7f19240155d0, driver=0x7f193411f1d0) at qemu/qemu_process.c:4196
      6  qemuProcessPrepareDomain (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=vm@entry=0x7f19240155d0, flags=flags@entry=17) at qemu/qemu_process.c:4969
      7  0x00007f193e4417c0 in qemuProcessStart (conn=conn@entry=0x7f192c00ab50, driver=driver@entry=0x7f193411f1d0, vm=0x7f19240155d0,asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_START, migrateFrom=migrateFrom@entry=0x0, migrateFd=migrateFd@entry=-1, migratePath=migratePath@entry=0x0,snapshot=snapshot@entry=0x0, vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=17, flags@entry=1) at qemu/qemu_process.c:5553
      
      Man page for getifaddrs also states that the "ifa_addr" may contain
      a null pointer which happens if there is an existing network interface
      on the host without IP address.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      (cherry picked from commit 42000bf7)
      2679eeea
    • J
      Increase default task limit for libvirtd · be3051bf
      Jim Fehlig 提交于
      libvirtd can spawn threads/tasks when creating new domains for
      some hypervisors such as Xen's libxl driver, quickly reaching
      the cgroups pids controller default TasksMax setting of 512. When
      the limit is reached, attempting to create additional domains
      results in an error from the cgroups pids controller, e.g.
      
      kernel: [71282.213347] cgroup: fork rejected by pids controller in
      /system.slice/libvirtd.service
      
      Depending on domain type and configuration, anywhere from 4-7
      threads/tasks may be created by libxl when starting a domain.
      In order to support 4096 domains, similar to commit 27cd7635,
      increase the TasksMax setting in libvirtd.service to
      4096 * 8 = 32768 tasks.
      
      (cherry picked from commit 6b3fb86b)
      be3051bf
    • D
      Fix error reporting when poll returns POLLHUP/POLLERR · de609c01
      Daniel P. Berrange 提交于
      In the RPC client event loop code, if poll() returns only a POLLHUP
      or POLLERR status, then we end up reporting a bogus error message:
      
        error: failed to connect to the hypervisor
        error: An error occurred, but the cause is unknown
      
      We do actually report an error, but we virNetClientMarkClose method
      has already captured the error status before we report it, so the
      real error gets thrown away. The key fix is to report the error
      before calling virNetClientMarkClose(). In changing this, we also
      split out reporting of POLLHUP vs POLLERR to make any future bugs
      easier to diagnose.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      (cherry picked from commit 234ac4e1)
      de609c01
    • J
      spec: Avoid RPM verification errors on nwfilter XMLs · 6611f380
      Jiri Denemark 提交于
      /etc/libvirt/nwfilter/*.xml files are installed with no UUID, which
      means libvirtd will automatically alter all of them once it starts. Thus
      RPM verification will always fail on them. Let's use a trick similar to
      the default network XML and store nwfilter XMLs in /usr/share. They will
      be copied into /etc in %post. Additionally the /etc files are marked as
      %ghost so that they are uninstalled if the RPM package is removed.
      
      Note that the %post script overwrites existing files with new ones on
      upgrade, which is what has always been happening.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1431581
      https://bugzilla.redhat.com/show_bug.cgi?id=1378774Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      (cherry picked from commit 1d3963db)
      6611f380
    • J
      xenconfig: avoid double free on OOM testing · 79e09184
      Jim Fehlig 提交于
      Fix xlconfig channel tests when OOM testing is enabled.
      
      TEST: xlconfigtest
      32) Xen XL-2-XML Format channel-unix                                  ... OK
          Test OOM for nalloc=55 ................................................*** Error in `/home/jfehlig/virt/upstream/libvirt/tests/.libs/xlconfigtest': double free or corruption (fasttop): 0x0000000000679550 ***
      ...
      (gdb) bt
      #0  0x00007ffff36875af in raise () from /lib64/libc.so.6
      #1  0x00007ffff36889aa in abort () from /lib64/libc.so.6
      #2  0x00007ffff36c5150 in __libc_message () from /lib64/libc.so.6
      #3  0x00007ffff36cb4f6 in malloc_printerr () from /lib64/libc.so.6
      #4  0x00007ffff36cbcee in _int_free () from /lib64/libc.so.6
      #5  0x00007ffff782babf in virFree (ptrptr=0x7fffffffdca8) at util/viralloc.c:582
      #6  0x000000000042f2f3 in xenParseXLChannel (conf=0x677350, def=0x6815b0) at xenconfig/xen_xl.c:788
      #7  0x000000000042f44e in xenParseXL (conf=0x677350, caps=0x6832b0, xmlopt=0x67f6e0) at xenconfig/xen_xl.c:828
      #8  0x00000000004105a3 in testCompareFormatXML (
          xlcfg=0x6811e0 "/home/jfehlig/virt/upstream/libvirt/tests/xlconfigdata/test-channel-unix.cfg",
          xml=0x681110 "/home/jfehlig/virt/upstream/libvirt/tests/xlconfigdata/test-channel-unix.xml", replaceVars=false)
          at xlconfigtest.c:152
      
      When a channel is successfully parsed and its path and name fields
      assigned from local variables, set the local variables to NULL to
      prevent a double free on error.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      (cherry picked from commit b2c12f57)
      79e09184
    • W
      xenFormatXLDomainDisks: avoid double free on OOM testing · 48158a8b
      Wim ten Have 提交于
      Fix xlconfigtest runs build for --enable-test-oom on
              Xen XL-2-XML Parse  new-disk
      
          #0  0x00007ffff3bd791f in raise () from /lib64/libc.so.6
          #1  0x00007ffff3bd951a in abort () from /lib64/libc.so.6
          #2  0x00007ffff3c1b200 in __libc_message () from /lib64/libc.so.6
          #3  0x00007ffff3c2488a in _int_free () from /lib64/libc.so.6
          #4  0x00007ffff3c282bc in free () from /lib64/libc.so.6
          #5  0x00007ffff7864fcb in virFree (ptrptr=ptrptr@entry=0x7fffffffd868) at util/viralloc.c:582
          #6  0x00007ffff78776e5 in virConfFreeValue (val=<optimized out>) at util/virconf.c:178
      ==> #7  0x0000000000425759 in xenFormatXLDomainDisks (def=0x7fffffffd8c0, def=0x7fffffffd8c0, conf=0x658220)
              at xenconfig/xen_xl.c:1159
          #8  xenFormatXL (def=def@entry=0x66ec20, conn=conn@entry=0x668cf0) at xenconfig/xen_xl.c:1558
          #9  0x000000000040ea1d in testCompareParseXML (replaceVars=<optimized out>,
              xml=0x65f5e0 "/home/wtenhave/WORK/libvirt/history/libvirt/tests/xlconfigdata/test-fullvirt-ovmf.xml",
              xlcfg=0x65f6b0 "/home/wtenhave/WORK/libvirt/history/libvirt/tests/xlconfigdata/test-fullvirt-ovmf.cfg")
              at xlconfigtest.c:105
          #10 testCompareHelper (data=<optimized out>) at xlconfigtest.c:205
          #11 0x000000000041079a in virTestRun (title=title@entry=0x431cf0 "Xen XL-2-XML Parse  fullvirt-ovmf",
              body=body@entry=0x40e720 <testCompareHelper>, data=data@entry=0x7fffffffda50) at testutils.c:247
          #12 0x000000000040ebc2 in mymain () at xlconfigtest.c:256
          #13 0x0000000000411070 in virTestMain (argc=1, argv=0x7fffffffdc08, func=0x40f2c0 <mymain>) at testutils.c:992
          #14 0x00007ffff3bc2401 in __libc_start_main () from /lib64/libc.so.6
          #15 0x000000000040e5da in _start ()
      
      symmetry seems missing its sibbling coded functionality
      demonstrated under functions;
              xenFormatXLUSBController()
              xenFormatXLUSB()
              xenFormatXLDomainChannels()
              xenFormatXMDisks
      Signed-off-by: NWim ten Have <wim.ten.have@oracle.com>
      (cherry picked from commit 2c1a31a3)
      48158a8b
    • W
      virConfSaveValue: protect against a NULL pointer reference · 9a2ed8c0
      Wim ten Have 提交于
      Fix xlconfigtest runs build for --enable-test-oom on
              Xen XL-2-XML Parse  channel-pty
      
      Program received signal SIGSEGV, Segmentation fault.
      
          #0  0x00007ffff3c2b373 in __strchr_sse2 () from /lib64/libc.so.6
      ==> #1  0x00007ffff7875701 in virConfSaveValue (buf=buf@entry=0x7fffffffd8a0, val=val@entry=0x674750) at util/virconf.c:290
          #2  0x00007ffff7875668 in virConfSaveValue (buf=buf@entry=0x7fffffffd8a0, val=<optimized out>) at util/virconf.c:306
          #3  0x00007ffff78757ef in virConfSaveEntry (buf=buf@entry=0x7fffffffd8a0, cur=cur@entry=0x674780) at util/virconf.c:338
          #4  0x00007ffff78783eb in virConfWriteMem (memory=0x665570 "", len=len@entry=0x7fffffffd910, conf=conf@entry=0x65b940)
              at util/virconf.c:1543
          #5  0x000000000040eccb in testCompareParseXML (replaceVars=<optimized out>, xml=<optimized out>,
              xlcfg=0x662c00 "/home/wtenhave/WORK/libvirt/OOMtesting/libvirt-devel/tests/xlconfigdata/test-channel-pty.cfg")
              at xlconfigtest.c:108
          #6  testCompareHelper (data=<optimized out>) at xlconfigtest.c:205
          #7  0x0000000000410b3a in virTestRun (title=title@entry=0x432cc0 "Xen XL-2-XML Parse  channel-pty",
              body=body@entry=0x40e9b0 <testCompareHelper>, data=data@entry=0x7fffffffd9f0) at testutils.c:247
          #8  0x000000000040f322 in mymain () at xlconfigtest.c:278
          #9  0x0000000000411410 in virTestMain (argc=1, argv=0x7fffffffdba8, func=0x40f660 <mymain>) at testutils.c:992
          #10 0x00007ffff3bc0401 in __libc_start_main () from /lib64/libc.so.6
          #11 0x000000000040e86a in _start ()
      
          (gdb) frame 1
          #1  0x00007ffff7875701 in virConfSaveValue (buf=buf@entry=0x7fffffffd8a0, val=val@entry=0x674750) at util/virconf.c:290
          290                 if (strchr(val->str, '\n') != NULL) {
          (gdb) print *val
          $1 = {type = VIR_CONF_STRING, next = 0x0, l = 0, str = 0x0, list = 0x0}
      Signed-off-by: NWim ten Have <wim.ten.have@oracle.com>
      (cherry picked from commit ae5d7582)
      9a2ed8c0
    • J
      conf: Add check for non scsi_host parent during vport delete · 5040c8da
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1420740
      
      If the parent is not a scsi_host, then we can just happily return since
      we won't be removing a vport.
      
      Fixes a bug with the following output:
      
      $ virsh pool-destroy host4_hba_pool
      error: Failed to destroy pool host4_hba_pool
      error: internal error: Invalid adapter name 'pci_0000_10_00_1' for SCSI pool
      
      $
      
      (cherry picked from commit 84f178bd)
      5040c8da
    • W
      util: Fix resource leak · 268c7e08
      Wang King 提交于
      The virRotatingFileWriterAppend method leaks the file->entry
      on the virRotatingFileWriterEntryNew failing path.
      
      (cherry picked from commit 123770cd)
      268c7e08
    • W
      test: Remove unused variate @maxcpu in testDomainGetVcpus · 0c20c909
      Wang King 提交于
      Since refactoring by commit id '3dd859c0', @maxcpu is no longer used.
      
      (cherry picked from commit b2641b43)
      0c20c909
    • W
      esx: Fix memory leak · 3e790949
      Wang King 提交于
      Variable def going out of scope leaks the storage def.source.hosts points to.
      
      (cherry picked from commit d76267b2)
      3e790949
    • W
      esx: Fix incorrect memory compare size in esxStoragePoolLookupByUUID · e0af3fd5
      Wang King 提交于
      Use MD5_DIGEST_SIZE or VIR_UUID_BUFLEN rather than VIR_UUID_STRING_BUFLEN
      when compare @uuid with @md5.
      
      (cherry picked from commit 77cc51a4)
      e0af3fd5
    • P
      qemu: snapshot: Skip empty drives with internal snapshots · 2c593526
      Peter Krempa 提交于
      The code that validates whether an internal snapshot is possible would
      reject an empty but not-readonly drive. Since floppies can have this
      property, add a check for emptiness.
      
      (cherry picked from commit eee3b4b9)
      2c593526
    • J
      qemu: do not crash on USB address with no port and invalid bus · e62d61e7
      Ján Tomko 提交于
      Properly error out when the user requests a port from a bus
      that does not have a controller present in the domain XML.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1441589
      (cherry picked from commit b003b978)
      e62d61e7
    • M
      man: Align vol-resize arguments with the output of help · 670102c0
      Martin Kletzander 提交于
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      (cherry picked from commit c3d1df7b)
      670102c0
    • P
      qemu: conf: Don't leak snapshot image format conf variable · c4d7361f
      Peter Krempa 提交于
      ==20406== 4 bytes in 1 blocks are definitely lost in loss record 6 of 1,059
      ==20406==    at 0x4C2AF3F: malloc (vg_replace_malloc.c:299)
      ==20406==    by 0x8F17D39: strdup (in /lib64/libc-2.24.so)
      ==20406==    by 0x552C0E0: virStrdup (virstring.c:784)
      ==20406==    by 0x54D3622: virConfGetValueString (virconf.c:945)
      ==20406==    by 0x144E4692: virQEMUDriverConfigLoadFile (qemu_conf.c:687)
      ==20406==    by 0x1452A744: qemuStateInitialize (qemu_driver.c:664)
      ==20406==    by 0x55DB585: virStateInitialize (libvirt.c:770)
      ==20406==    by 0x124570: daemonRunStateInit (libvirtd.c:881)
      ==20406==    by 0x5532990: virThreadHelper (virthread.c:206)
      ==20406==    by 0x8C82493: start_thread (in /lib64/libpthread-2.24.so)
      ==20406==    by 0x8F7FA1E: clone (in /lib64/libc-2.24.so)
      
      (cherry picked from commit 2ef3aa8f)
      c4d7361f
    • E
      qemu: Fix mdev checking for VFIO support · 1cf9493e
      Erik Skultety 提交于
      Commit a4a39d90 added a check that checks for VFIO support with mediated
      devices. The problem is that the hostdev preparing functions behave like
      a fallthrough if device of that specific type doesn't exist. However,
      the check for VFIO support was independent of the existence of a mdev
      device which caused the guest to fail to start with any device to be
      directly assigned if VFIO was disabled/unavailable in the kernel.
      The proposed change first ensures that it makes sense to check for VFIO
      support in the first place, and only then performs the VFIO support check
      itself.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1441291Signed-off-by: NErik Skultety <eskultet@redhat.com>
      (cherry picked from commit b4c2ac8d)
      1cf9493e
    • W
      util: systemd: Don't strlen a possibly NULL string · 679aa190
      Wang King 提交于
      Coverity complains about virBufferCurrentContent might be return null
      when calling strlen, so check virBufferError first before calling
      strlen.
      
      (cherry picked from commit c5ca209f)
      679aa190
    • W
      interface: Fix resource leak in netcfConnectListAllInterfaces error path · a7aacb74
      Wang King 提交于
      On virGetInterface failure, call virInterfaceDefFree for the @def.
      
      (cherry picked from commit 1b1b0459)
      a7aacb74
    • W
      virsh: don't leak @cpumap in virshVcpuPinQuery · dce5c95c
      Wang King 提交于
      ==18591== 16 bytes in 1 blocks are definitely lost in loss record 41 of 183
      ==18591==    at 0x4C2B934: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==18591==    by 0x54EBB1C: virAllocN (viralloc.c:191)
      ==18591==    by 0x1628CA: _vshMalloc (vsh.c:136)
      ==18591==    by 0x1344C4: virshVcpuPinQuery (virsh-domain.c:6603)
      ==18591==    by 0x1344C4: cmdVcpuPin (virsh-domain.c:6707)
      ==18591==    by 0x1631BF: vshCommandRun (vsh.c:1312)
      ==18591==    by 0x12DBB1: main (virsh.c:961)
      
      (cherry picked from commit b1aa4613)
      dce5c95c
    • P
      tests: fix some resource leaks · 3cfd60b1
      Pavel Hrdina 提交于
      Found by running valgrind for these tests.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      (cherry picked from commit 9005a64b)
      3cfd60b1
    • P
      rpc: fix resource leak · e675e874
      Pavel Hrdina 提交于
      Commit 252610f7 switched to use hash to store servers.
      Function virHashGetItems returns allocated array which needs
      to be freed also for successful path, not only if there is
      an error.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      (cherry picked from commit ab0a461b)
      e675e874
    • P
      src: fix multiple resource leaks in loops · c714afcc
      Pavel Hrdina 提交于
      All of the variables are filled inside a loop and therefore
      needs to be also freed in every cycle.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      (cherry picked from commit ffc810b7)
      c714afcc
    • P
      conf/domain_capabilities: fix resource leak · fdd08607
      Pavel Hrdina 提交于
      Commit 14319c81 introduced CPU host model in domain capabilities
      and the *hostmodel* variable is always filled by virCPUDefCopy()
      and needs to be freed.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      (cherry picked from commit 87d97a9d)
      fdd08607
    • M
      qemu: Fix two use-after-free situations · 9a47afb1
      Marc Hartmayer 提交于
      There were multiple race conditions that could lead to segmentation
      faults. The first precondition for this is qemuProcessLaunch must fail
      sometime shortly after starting the new QEMU process. The second
      precondition for the segmentation faults is that the new QEMU process
      dies - or to be more precise the QEMU monitor has to be closed
      irregularly. If both happens during qemuProcessStart (starting a
      domain) there are race windows between the thread with the event
      loop (T1) and the thread that is starting the domain (T2).
      
      First segmentation fault scenario:
      If qemuProcessLaunch fails during qemuProcessStart the code branches
      to the 'stop' path where 'qemuMonitorSetDomainLog(priv->mon, NULL,
      NULL, NULL)' will set the log function of the monitor to NULL (done in
      T2). In the meantime the event loop of T1 will wake up with an EOF
      event for the QEMU monitor because the QEMU process has died. The
      crash occurs if T1 has checked 'mon->logFunc != NULL' in qemuMonitorIO
      just before the logFunc was set to NULL by T2. If this situation
      occurs T1 will try to call mon->logFunc which leads to the
      segmentation fault.
      
      Solution:
      Require the monitor lock for setting the log function.
      
      Backtrace:
      0  0x0000000000000000 in ?? ()
      1  0x000003ffe9e45316 in qemuMonitorIO (watch=<optimized out>,
      fd=<optimized out>, events=<optimized out>, opaque=0x3ffe08aa860) at
      ../../src/qemu/qemu_monitor.c:727
      2  0x000003fffda2e1a4 in virEventPollDispatchHandles (nfds=<optimized
      out>, fds=0x2aa000fd980) at ../../src/util/vireventpoll.c:508
      3  0x000003fffda2e398 in virEventPollRunOnce () at
      ../../src/util/vireventpoll.c:657
      4  0x000003fffda2ca10 in virEventRunDefaultImpl () at
      ../../src/util/virevent.c:314
      5  0x000003fffdba9366 in virNetDaemonRun (dmn=0x2aa000cc550) at
      ../../src/rpc/virnetdaemon.c:818
      6  0x000002aa00024668 in main (argc=<optimized out>, argv=<optimized
      out>) at ../../daemon/libvirtd.c:1541
      
      Second segmentation fault scenario:
      If qemuProcessLaunch fails it will unref the log context and with
      invoking qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL)
      qemuDomainLogContextFree() will be invoked. qemuDomainLogContextFree()
      invokes virNetClientClose() to close the client and cleans everything
      up (including unref of _virLogManager.client) when virNetClientClose()
      returns. When T1 is now trying to report 'qemu unexpectedly closed the
      monitor' libvirtd will crash because the client has already been
      freed.
      
      Solution:
      As the critical section in qemuMonitorIO is protected with the monitor
      lock we can use the same solution as proposed for the first
      segmentation fault.
      
      Backtrace:
      0  virClassIsDerivedFrom (klass=0x3100979797979797,
      parent=0x2aa000d92f0) at ../../src/util/virobject.c:169
      1  0x000003fffda659e6 in virObjectIsClass (anyobj=<optimized out>,
      klass=<optimized out>) at ../../src/util/virobject.c:365
      2  0x000003fffda65a24 in virObjectLock (anyobj=0x3ffe08c1db0) at
      ../../src/util/virobject.c:317
      3  0x000003fffdba4688 in
      virNetClientIOEventLoop (client=client@entry=0x3ffe08c1db0,
      thiscall=thiscall@entry=0x2aa000fbfa0) at
      ../../src/rpc/virnetclient.c:1668
      4  0x000003fffdba4b4c in
      virNetClientIO (client=client@entry=0x3ffe08c1db0,
      thiscall=0x2aa000fbfa0) at ../../src/rpc/virnetclient.c:1944
      5  0x000003fffdba4d42 in
      virNetClientSendInternal (client=client@entry=0x3ffe08c1db0,
      msg=msg@entry=0x2aa000cc710, expectReply=expectReply@entry=true,
      nonBlock=nonBlock@entry=false) at ../../src/rpc/virnetclient.c:2116
      6  0x000003fffdba6268 in
      virNetClientSendWithReply (client=0x3ffe08c1db0, msg=0x2aa000cc710) at
      ../../src/rpc/virnetclient.c:2144
      7  0x000003fffdba6e8e in virNetClientProgramCall (prog=0x3ffe08c1120,
      client=<optimized out>, serial=<optimized out>, proc=<optimized out>,
      noutfds=<optimized out>, outfds=0x0, ninfds=0x0, infds=0x0,
      args_filter=0x3fffdb64440
      <xdr_virLogManagerProtocolDomainReadLogFileArgs>, args=0x3ffffffe010,
      ret_filter=0x3fffdb644c0
      <xdr_virLogManagerProtocolDomainReadLogFileRet>, ret=0x3ffffffe008) at
      ../../src/rpc/virnetclientprogram.c:329
      8  0x000003fffdb64042 in
      virLogManagerDomainReadLogFile (mgr=<optimized out>, path=<optimized
      out>, inode=<optimized out>, offset=<optimized out>, maxlen=<optimized
      out>, flags=0) at ../../src/logging/log_manager.c:272
      9  0x000003ffe9e0315c in qemuDomainLogContextRead (ctxt=0x3ffe08c2980,
      msg=0x3ffffffe1c0) at ../../src/qemu/qemu_domain.c:4422
      10 0x000003ffe9e280a8 in qemuProcessReadLog (logCtxt=<optimized out>,
      msg=msg@entry=0x3ffffffe288) at ../../src/qemu/qemu_process.c:1800
      11 0x000003ffe9e28206 in qemuProcessReportLogError (logCtxt=<optimized
      out>, msgprefix=0x3ffe9ec276a "qemu unexpectedly closed the monitor")
      at ../../src/qemu/qemu_process.c:1836
      12 0x000003ffe9e28306 in
      qemuProcessMonitorReportLogError (mon=mon@entry=0x3ffe085cf10,
      msg=<optimized out>, opaque=<optimized out>) at
      ../../src/qemu/qemu_process.c:1856
      13 0x000003ffe9e452b6 in qemuMonitorIO (watch=<optimized out>,
      fd=<optimized out>, events=<optimized out>, opaque=0x3ffe085cf10) at
      ../../src/qemu/qemu_monitor.c:726
      14 0x000003fffda2e1a4 in virEventPollDispatchHandles (nfds=<optimized
      out>, fds=0x2aa000fd980) at ../../src/util/vireventpoll.c:508
      15 0x000003fffda2e398 in virEventPollRunOnce () at
      ../../src/util/vireventpoll.c:657
      16 0x000003fffda2ca10 in virEventRunDefaultImpl () at
      ../../src/util/virevent.c:314
      17 0x000003fffdba9366 in virNetDaemonRun (dmn=0x2aa000cc550) at
      ../../src/rpc/virnetdaemon.c:818
      18 0x000002aa00024668 in main (argc=<optimized out>, argv=<optimized
      out>) at ../../daemon/libvirtd.c:1541
      
      Other code parts where the same problem was possible to occur are
      fixed as well (qemuMigrationFinish, qemuProcessStart, and
      qemuDomainSaveImageStartVM).
      Signed-off-by: NMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
      Reported-by: NSascha Silbe <silbe@linux.vnet.ibm.com>
      (cherry picked from commit 20e95cb7)
      9a47afb1
    • J
      disk: Force usage of parted when checking disk format for "bsd" · a45034e1
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1439132
      
      Add "bsd" to the list of format types to not checked during blkid
      processing even though it supposedly knows the format - for some
      (now unknown) reason it's returning partition table not found. So
      let's just let PARTED handle "bsd" too.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      (cherry picked from commit 98f424d5)
      a45034e1
    • J
      disk: Resolve issues with disk partition build/start checks · facbb1f0
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1439132
      
      Commit id 'a48c674f' added a check for format types "dvh" and "pc98"
      to use the parted print processing instead of using blkid processing
      in order to validate the label on the disk was what is expected for
      disk pool startup. However, commit id 'a4cb4a74' really messed things
      up by missing an else condition causing PARTEDFindLabel to always
      return DIFFERENT.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      (cherry picked from commit f2a12320)
      facbb1f0
    • P
      conf: create new RemovalFailed event using correct class · e495bdef
      Pavel Hrdina 提交于
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      (cherry picked from commit be193c4d)
      e495bdef