1. 16 2月, 2012 1 次提交
    • L
      qemu: drop driver lock while trying to terminate qemu process · 595e26c0
      Laine Stump 提交于
      This patch is based on an earlier patch by Eric Blake which was never
      committed:
      
      https://www.redhat.com/archives/libvir-list/2011-November/msg00243.html
      
      Aside from rebasing, this patch only drops the driver lock once (prior
      to the first time the function sleeps), then leaves it dropped until
      it returns (Eric's patch would drop and re-acquire the lock around
      each call to sleep).
      
      At the time Eric sent his patch, the response (from Dan Berrange) was
      that, while it wasn't a good thing to be holding the driver lock while
      sleeping, we really need to rethink locking wrt the driver object,
      switching to a finer-grained approach that locks individual items
      within the driver object separately to allow for greater concurrency.
      
      This is a good plan, and at the time it made sense to not apply the
      patch because there was no known bug related to the driver lock being
      held in this function.
      
      However, we now know that the length of the wait in qemuProcessKill is
      sometimes too short to allow the qemu process to fully flush its disk
      cache before SIGKILL is sent, so we need to lengthen the timeout (in
      order to improve the situation with management applications until they
      can be updated to use the new VIR_DOMAIN_DESTROY_GRACEFUL flag added
      in commit 72f8a7f1). But, if we
      lengthen the timeout, we also lengthen the amount of time that all
      other threads in libvirtd are essentially blocked from doing anything
      (since just about everything needs to acquire the driver lock, if only
      for long enough to get a pointer to a domain).
      
      The solution is to modify qemuProcessKill to drop the driver lock
      while sleeping, as proposed in Eric's patch. Then we can increase the
      timeout with a clear conscience, and thus at least lower the chances
      that someone running with existing management software will suffer the
      consequence's of qemu's disk cache not being flushed.
      
      In the meantime, we still should work on Dan's proposal to make
      locking within the driver object more fine grained.
      
      (NB: although I couldn't find any instance where qemuProcessKill() was
      called with no jobs active for the domain (or some other guarantee
      that the current thread had at least one refcount on the domain
      object), this patch still follows Eric's method of temporarily adding
      a ref prior to unlocking the domain object, because I couldn't
      convince myself 100% that this was the case.)
      595e26c0
  2. 15 2月, 2012 2 次提交
  3. 14 2月, 2012 1 次提交
    • E
      qemu: make block io tuning smarter · 172d3429
      Eric Blake 提交于
      When blkdeviotune was first committed in 0.9.8, we had the limitation
      that setting one value reset all others.  But bytes and iops should
      be relatively independent.  Furthermore, setting tuning values on
      a live domain followed by dumpxml did not output the new settings.
      
      * src/qemu/qemu_driver.c (qemuDiskPathToAlias): Add parameter, and
      update callers.
      (qemuDomainSetBlockIoTune): Don't lose previous unrelated
      settings.  Make live changes reflect to dumpxml output.
      * tools/virsh.pod (blkdeviotune): Update documentation.
      172d3429
  4. 13 2月, 2012 3 次提交
  5. 11 2月, 2012 1 次提交
  6. 10 2月, 2012 6 次提交
    • O
      util: Do not use PRIx64 macro · 2bcfd5b1
      Osier Yang 提交于
      It breaks the build on Mingw32,  because PRIx64 is coming
      from the Win32 headers, but virAsprintf uses the gnulib printf.
      2bcfd5b1
    • A
      rpc: Plug memory leaks on doRemoteOpen() failure path · 6d514728
      Alex Jia 提交于
      Detected by valgrind. Leaks are introduced in commit c1b22644.
      
      * src/remote/remote_driver.c (doRemoteOpen): free client program memory in failure path.
      
      * How to reproduce?
      % valgrind -v --leak-check=full virsh -c qemu:
      
      * Actual result
      
      ==3969== 40 bytes in 1 blocks are definitely lost in loss record 8 of 28
      ==3969==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
          ==3969==    by 0x4C89C41: virAlloc (memory.c:101)
          ==3969==    by 0x4D5A236: virNetClientProgramNew (virnetclientprogram.c:60)
          ==3969==    by 0x4D47AB4: doRemoteOpen (remote_driver.c:658)
          ==3969==    by 0x4D49FFF: remoteOpen (remote_driver.c:871)
          ==3969==    by 0x4D13373: do_open (libvirt.c:1196)
          ==3969==    by 0x4D14535: virConnectOpenAuth (libvirt.c:1422)
          ==3969==    by 0x425627: main (virsh.c:18537)
          ==3969==
          ==3969== 40 bytes in 1 blocks are definitely lost in loss record 9 of 28
          ==3969==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
          ==3969==    by 0x4C89C41: virAlloc (memory.c:101)
          ==3969==    by 0x4D5A236: virNetClientProgramNew (virnetclientprogram.c:60)
          ==3969==    by 0x4D47AD7: doRemoteOpen (remote_driver.c:664)
          ==3969==    by 0x4D49FFF: remoteOpen (remote_driver.c:871)
          ==3969==    by 0x4D13373: do_open (libvirt.c:1196)
          ==3969==    by 0x4D14535: virConnectOpenAuth (libvirt.c:1422)
          ==3969==    by 0x425627: main (virsh.c:18537)
          ==3969==
          ==3969== LEAK SUMMARY:
          ==3969==    definitely lost: 80 bytes in 2 blocks
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      6d514728
    • O
      npiv: Auto-generate WWN if it's not specified · 7c90026d
      Osier Yang 提交于
      The auto-generated WWN comply with the new addressing schema of WWN:
      
      <quote>
      the first nibble is either hex 5 or 6 followed by a 3-byte vendor
      identifier and 36 bits for a vendor-specified serial number.
      </quote>
      
      We choose hex 5 for the first nibble. And for the 3-bytes vendor ID,
      we uses the OUI according to underlying hypervisor type, (invoking
      virConnectGetType to get the virt type). e.g. If virConnectGetType
      returns "QEMU", we use Qumranet's OUI (00:1A:4A), if returns
      ESX|VMWARE, we use VMWARE's OUI (00:05:69). Currently it only
      supports qemu|xen|libxl|xenapi|hyperv|esx|vmware drivers. The last
      36 bits are auto-generated.
      7c90026d
    • M
      Remove single quotes from audit records · 8ac1f8f4
      Marcelo Cerri 提交于
      Some audit records generated by libvirt contain fields enclosed by single
      quotes. Since those fields are inside the msg field, which is enclosed by
      single quotes, these records generated by libvirt are not correctly parsed by
      libauparse.
      8ac1f8f4
    • L
      GetCPUStats: fix overflow test · f9f2d3b1
      Lai Jiangshan 提交于
      Bug introduced in commit c6ec021b.
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      f9f2d3b1
    • M
      domain: add implicit USB controller · 42043afc
      Marc-André Lureau 提交于
      Some tools, such as virt-manager, prefers having the default USB
      controller explicit in the XML document. This patch makes sure there
      is one. With this patch, it is now possible to switch from USB1 to
      USB2 from the release 0.9.1 of virt-manager.
      
      Fix tests to pass with this change.
      42043afc
  7. 09 2月, 2012 7 次提交
  8. 08 2月, 2012 8 次提交
    • J
      qemu: Fix memory leak when building -cpu argument · 91ca45f9
      Jiri Denemark 提交于
      Reported by Alex Jia:
      
      ==21503== 112 (32 direct, 80 indirect) bytes in 1 blocks are
      definitely lost in loss record 37 of 40
      ==21503==    at 0x4A04A28: calloc (vg_replace_malloc.c:467)
      ==21503==    by 0x4A8991: virAlloc (memory.c:101)
      ==21503==    by 0x505A6C: x86DataCopy (cpu_x86.c:247)
      ==21503==    by 0x507B34: x86Compute (cpu_x86.c:1225)
      ==21503==    by 0x43103C: qemuBuildCommandLine (qemu_command.c:3561)
      ==21503==    by 0x41C9F7: testCompareXMLToArgvHelper
      (qemuxml2argvtest.c:183)
      ==21503==    by 0x41E10D: virtTestRun (testutils.c:141)
      ==21503==    by 0x41B942: mymain (qemuxml2argvtest.c:705)
      ==21503==    by 0x41D7E7: virtTestMain (testutils.c:696)
      91ca45f9
    • J
      qemu: Always use iohelper for domain save · c4caab53
      Jiri Denemark 提交于
      This is probably not strictly needed as save operation is not live but
      we may have other reasons to avoid blocking qemu's main loop.
      c4caab53
    • J
      security: Driver 'none' cannot create confined guests · afb96301
      Jiri Denemark 提交于
      In case the caller specifies that confined guests are required but the
      security driver turns out to be 'none', we should return an error since
      this driver clearly cannot meet that requirement.  As a result of this
      error, libvirtd fails to start when the host admin explicitly sets
      confined guests are required but there is no security driver available.
      
      Since security driver 'none' cannot create confined guests, we override
      default confined setting so that hypervisor drivers do not thing they
      should create confined guests.
      afb96301
    • J
      seclabel: Do not output relabel attribute for type 'none' · f6957617
      Jiri Denemark 提交于
      Security label type 'none' requires relabel to be set to 'no' so there's
      no reason to output this extra attribute.  Moreover, since relabel is
      internally stored in a negative from (norelabel), the default value for
      relabel would be 'yes' in case there is no <seclabel> element in domain
      configuration.  In case VIR_DOMAIN_SECLABEL_DEFAULT turns into
      VIR_DOMAIN_SECLABEL_NONE, we would incorrectly output relabel='yes' for
      seclabel type 'none'.
      f6957617
    • J
      qemu: Always use iohelper for dumping domain core · c8683f23
      Jiri Denemark 提交于
      Qemu uses non-blocking I/O which doesn't play nice with regular file
      descriptors. We need to pass a pipe to qemu instead, which can easily be
      done using iohelper.
      c8683f23
    • J
      util: Generalize virFileDirectFd · afe6e58a
      Jiri Denemark 提交于
      virFileDirectFd was used for accessing files opened with O_DIRECT using
      libvirt_iohelper. We will want to use the helper for accessing files
      regardless on O_DIRECT and thus virFileDirectFd was generalized and
      renamed to virFileWrapperFd.
      afe6e58a
    • P
      On systems with dmidecode version 2.10 or older, · a76530c9
      Prerna Saxena 提交于
       dmidecode displays processor information, followed by BIOS, system and
       memory-DIMM details.
       Calls to virSysinfoParseBIOS(), virSysinfoParseSystem() would update
       the buffer pointer 'base', so the processor information would be lost
       before virSysinfoParseProcessor() was called. Sysinfo would therefore
       not be able to display processor details -- It only described <bios>,
       <system> and <memory_device> details.
       This patch attempts to insulate sysinfo from ordering of dmidecode
       output.
      
      Before the fix:
      ---------------
      virsh # sysinfo
      <sysinfo type='smbios'>
        <bios>
          ....
        </bios>
        <system>
          ....
        </system>
        <memory_device>
          ....
        </memory_device>
      
      After the fix:
      -------------
      virsh # sysinfo
      <sysinfo type='smbios'>
        <bios>
          ....
        </bios>
        <system>
          ....
        </system>
        <processor>
          ....
        </processor>
        <memory_device>
          ....
        </memory_device>
      a76530c9
    • C
      storage: Don't unsparsify images when cloning · 0ed86cfb
      Cole Robinson 提交于
      Input to the volume cloning code is a source volume and an XML
      descriptor for the new volume. It is possible for the new volume
      to have a greater size than source volume, at which point libvirt
      will just stick 0s on the end of the new image (for raw format
      anyways).
      
      Unfortunately a logic error messed up our tracking of the of the
      excess amount that needed to be written: end result is that sparse
      clones were made very much non-sparse, and cloning regular disk
      images could end up excessively sized (though data unaltered).
      
      Drop the 'remain' variable entriely here since it's redundant, and
      track actual allocation directly against the desired 'total'.
      0ed86cfb
  9. 07 2月, 2012 4 次提交
    • E
      build: avoid gcc 4.7 warning about inlines · 32b2e5a8
      Eric Blake 提交于
      gcc 4.7 complains:
      
      util/virhashcode.c:49:17: error: always_inline function might not be inlinable [-Werror=attributes]
      util/virhashcode.c:35:17: error: always_inline function might not be inlinable [-Werror=attributes]
      
      Normal 'inline' is a hint that the compiler may ignore; the fact
      that the function is static is good enough.  We don't care if the
      compiler decided not to inline after all.
      
      * src/util/virhashcode.c (getblock, fmix): Relax attribute.
      32b2e5a8
    • P
      xen-xm: SIGSEGV in xenXMDomainDefineXML: filename · 360afebf
      Philipp Hahn 提交于
      filename is not initialized to NULL while it's unconditionally freed in
      the error path.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      360afebf
    • P
      xen-xm: fix data loss in domain edit · 700102c9
      Philipp Hahn 提交于
      On CentOS5:
      If "virsh edit $DOM" is used and an error happens (for example changing
      any live cycle action to a non-existing value), libvirt forgets that
      $DOM exists, since it is already removed from the internal hash tables,
      which are used for domain lookup.
      In once case (unreproducible) even the persistent configuration
      /etc/xen/$DOM was deleted.
      
      Instead of using the compound function xenXMConfigSaveFile() explicitly
      use xenFomatXM() and virConfWriteFile() to distinguish between a failure
      in converting the libvirt definition to the xen-xm format and a problem
      when writing the file.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      700102c9
    • E
      seclabel: make code and RNG match · c052d8a8
      Eric Blake 提交于
      Commit b170eb99 introduced a bug: domains that had an explicit
      <seclabel type='none'/> when started would not be reparsed if
      libvirtd restarted.  It turns out that our testsuite was not
      exercising this because it never tried anything but inactive
      parsing.  Additionally, the live XML for such a domain failed
      to re-validate.  Applying just the tests/ portion of this patch
      will expose the bugs that are fixed by the other two files.
      
      * docs/schemas/domaincommon.rng (seclabel): Allow relabel under
      type='none'.
      * src/conf/domain_conf.c (virSecurityLabelDefParseXML): Per RNG,
      presence of <seclabel> with no type implies dynamic.  Don't
      require sub-elements for type='none'.
      * tests/qemuxml2xmltest.c (mymain): Add test.
      * tests/qemuxml2argvtest.c (mymain): Likewise.
      * tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml: Add file.
      * tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.args: Add file.
      Reported by Ansis Atteka.
      c052d8a8
  10. 06 2月, 2012 3 次提交
    • P
      xen_xm: Fix SIGSEGV in xenXMDomainDefineXML · 046b0a69
      Philipp Hahn 提交于
      On CentOS5 with xen-3.0.3:
      
       Program received signal SIGSEGV, Segmentation fault.
       virFree (ptrptr=0x8) at util/memory.c:310
       310         free(*(void**)ptrptr);
       (gdb) bt
       #0  virFree (ptrptr=0x8) at util/memory.c:310
       #1  0x00002aaaaae167c8 in xenXMDomainDefineXML (conn=0x694e80, xml=0x6b2ce0 "P\fk") at xen/xm_internal.c:1199
       #2  0x00002aaaaae070d7 in xenUnifiedDomainDefineXML (conn=0x8,
           xml=0x6ac040 "<domain type='xen'>\n  <name>pv</name>\n  <uuid>20291bc0-453a-4d6c-c6ac-4e5af63b932c</uuid>\n  <memory>1048576</memory>\n  <currentMemory>1048576</currentMemory>\n  <vcpu>1</vcpu>\n  <os>\n    <type arch='x8"...) at xen/xen_driver.c:1524
       #3  0x00002aaaaada7803 in virDomainDefineXML (conn=0x694e80,
           xml=0x6ac040 "<domain type='xen'>\n  <name>pv</name>\n  <uuid>20291bc0-453a-4d6c-c6ac-4e5af63b932c</uuid>\n  <memory>1048576</memory>\n  <currentMemory>1048576</currentMemory>\n  <vcpu>1</vcpu>\n  <os>\n    <type arch='x8"...) at libvirt.c:7823
       #4  0x0000000000426173 in cmdEdit (ctl=0x7fffffffb8e0, cmd=<value optimized out>) at virsh.c:14882
       #5  0x000000000041c9ce in vshCommandRun (ctl=0x7fffffffb8e0, cmd=0x658c50) at virsh.c:17712
       #6  0x000000000042c3b9 in main (argc=1, argv=<value optimized out>) at virsh.c:19317
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      046b0a69
    • J
      qemu: Fix seamless spice migration · d9d518b1
      Jiri Denemark 提交于
      Calling qemuDomainMigrateGraphicsRelocate notifies spice clients to
      connect to destination qemu so that they can seamlessly switch streams
      once migration is done. Unfortunately, current qemu is not able to
      accept any connections while incoming migration connection is open.
      Thus, we need to delay opening the migration connection to the point
      spice client is already connected to the destination qemu.
      d9d518b1
    • J
      apparmor: Add missing comma · 3ecc06f4
      Jiri Denemark 提交于
      Typo introduced by c18a88ac
      3ecc06f4
  11. 04 2月, 2012 4 次提交
    • E
      maint: consolidate several .gitignore files · 8f00276c
      Eric Blake 提交于
      Unlike .cvsignore under CVS, git allows for ignoring nested
      names.  We weren't very consistent where new tests were
      being ignored (some in .gitignore, some in tests/.gitignore),
      and I found it easier to just consolidate everything.
      
      * .gitignore: Subsume entries from subdirectories.
      * daemon/.gitignore: Delete.
      * docs/.gitignore: Likewise.
      * docs/devhelp/.gitignore: Likewise.
      * docs/html/.gitignore: Likewise.
      * examples/dominfo/.gitignore: Likewise.
      * examples/domsuspend/.gitignore: Likewise.
      * examples/hellolibvirt/.gitignore: Likewise.
      * examples/openauth/.gitignore: Likewise.
      * examples/domain-events/events-c/.gitignore: Likewise.
      * include/libvirt/.gitignore: Likewise.
      * src/.gitignore: Likewise.
      * src/esx/.gitignore: Likewise.
      * tests/.gitignore: Likewise.
      * tools/.gitignore: Likewise.
      8f00276c
    • L
      qemu: eliminate "Ignoring open failure" when using root-squash NFS · c18a88ac
      Laine Stump 提交于
      This eliminates the warning message reported in:
      
       https://bugzilla.redhat.com/show_bug.cgi?id=624447
      
      It was caused by a failure to open an image file that is not
      accessible by root (the uid libvirtd is running as) because it's on a
      root-squash NFS share, owned by a different user, with permissions of
      660 (or maybe 600).
      
      The solution is to use virFileOpenAs() rather than open(). The
      codepath that generates the error is during qemuSetupDiskCGroup(), but
      the actual open() is in a lower-level generic function called from
      many places (virDomainDiskDefForeachPath), so some other pieces of the
      code were touched just to add dummy (or possibly useful) uid and gid
      arguments.
      
      Eliminating this warning message has the nice side effect that the
      requested operation may even succeed (which in this case isn't
      necessary, but shouldn't hurt anything either).
      c18a88ac
    • L
      util: refactor virFileOpenAs · 90e4d681
      Laine Stump 提交于
      virFileOpenAs previously would only try opening a file as the current
      user, or as a different user, but wouldn't try both methods in a
      single call. This made it cumbersome to use as a replacement for
      open(2). Additionally, it had a lot of historical baggage that led to
      it being difficult to understand.
      
      This patch refactors virFileOpenAs in the following ways:
      
      * reorganize the code so that everything dealing with both the parent
        and child sides of the "fork+setuid+setgid+open" method are in a
        separate function. This makes the public function easier to understand.
      
      * Allow a single call to virFileOpenAs() to first attempt the open as
        the current user, and if that fails to automatically re-try after
        doing fork+setuid (if deemed appropriate, i.e. errno indicates it
        would now be successful, and the file is on a networkFS). This makes
        it possible (in many, but possibly not all, cases) to drop-in
        virFileOpenAs() as a replacement for open(2).
      
        (NB: currently qemuOpenFile() calls virFileOpenAs() twice, once
        without forking, then again with forking. That unfortunately can't
        be changed without at least some discussion of the ramifications,
        because the requested file permissions are different in each case,
        which is something that a single call to virFileOpenAs() can't deal
        with.)
      
      * Add a flag so that any fchown() of the file to a different uid:gid
        is explicitly requested when the function is called, rather than it
        being implied by the presence of the O_CREAT flag. This just makes
        for less subtle surprises to consumers. (Commit
        b1643dc1 added the check for O_CREAT
        before forcing ownership. This patch just makes that restriction
        more explicit.)
      
      * If either the uid or gid is specified as "-1", virFileOpenAs will
        interpret this to mean "the current [gu]id".
      
      All current consumers of virFileOpenAs should retain their present
      behavior (after a few minor changes to their setup code and
      arguments).
      90e4d681
    • D
      util: rename netlink.[ch] to virnetlink.[ch] · d0439428
      D. Herrendoerfer 提交于
      Rename the src/util/netlink files to src/util/virnetlink to
      better fit the naming scheme. Also rename nlComm to virNetlinkCommand.
      Signed-off-by: ND. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
      d0439428