1. 15 10月, 2011 1 次提交
    • O
      qemu: Do not reattach PCI device used by other domain when shutdown · 24b8be89
      Osier Yang 提交于
      When failing on starting a domain, it tries to reattach all the PCI
      devices defined in the domain conf, regardless of whether the devices
      are still used by other domain. This will cause the devices to be deleted
      from the list qemu_driver->activePciHostdevs, thus the devices will be
      thought as usable even if it's not true. And following commands
      nodedev-{reattach,reset} will be successful.
      
      How to reproduce:
        1) Define two domains with same PCI device defined in the confs.
        2) # virsh start domain1
        3) # virsh start domain2
        4) # virsh nodedev-reattach $pci_device
      
      You will see the device will be reattached to host successfully.
      As pciDeviceReattach just check if the device is still used by
      other domain via checking if the device is in list driver->activePciHostdevs,
      however, the device is deleted from the list by step 2).
      
      This patch is to prohibit the bug by:
        1) Prohibit a domain starting or device attachment right at
           preparation period (qemuPrepareHostdevPCIDevices) if the
           device is in list driver->activePciHostdevs, which means
           it's used by other domain.
      
        2) Introduces a new field for struct _pciDevice, (const char *used_by),
           it will be set as the domain name at preparation period,
           (qemuPrepareHostdevPCIDevices). Thus we can prohibit deleting
           the device from driver->activePciHostdevs if it's still used by
           other domain when stopping the domain process.
      
      * src/pci.h (define two internal functions, pciDeviceSetUsedBy and
          pciDevceGetUsedBy)
      * src/pci.c (new field "const char *used_by" for struct _pciDevice,
          implementations for the two new functions)
      * src/libvirt_private.syms (Add the two new internal functions)
      * src/qemu_hostdev.h (Modify the definition of functions
          qemuPrepareHostdevPCIDevices, and qemuDomainReAttachHostdevDevices)
      * src/qemu_hostdev.c (Prohibit preparation and don't delete the
          device from activePciHostdevs list if it's still used by other domain)
      * src/qemu_hotplug.c (Update function usage, as the definitions are
          changed)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      24b8be89
  2. 14 10月, 2011 20 次提交
    • P
      Xen: Fake versions in xencapstest · 435b9d99
      Philipp Hahn 提交于
      virInitialize() → xenRegister() → xenhypervisorInit() determines the
      version of the Hypervisor. This breaks xencapstest when building as root
      on a dom0 system, since xenHypervisorBuildCapabilities() adds the "hap"
      and "viridian" features based on the detected version.
      
      Add an optional parameter to xenhypervisorInit() to disable automatic
      detection of the Hypervisor version. The passed in arguments are used
      instead.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      435b9d99
    • P
      Xen: move versions to struct · 618758c9
      Philipp Hahn 提交于
      Calling virInitialize() → xenRegister() → xenhypervisorInit() directly
      opens a connection to the Xen Hypervisor, which breaks some unit tests.
      
      Move all static variables into a struct to make it easier to override
      them when testing.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      618758c9
    • E
      esx: drop dead code to silence Coverity · 1518042b
      Eric Blake 提交于
      Coverity detected that the only way to get to the cleanup label
      is if objectSpec had been successfully allocated, so the null
      check was dead code.
      
      * src/esx/esx_vi.c (esxVI_LookupObjectContentByType): Drop
      redundant null check.
      1518042b
    • J
      util: Fix typo in virGetHostname description · 57d91fca
      Jiri Denemark 提交于
      57d91fca
    • E
      macvtap: plug memory leak for 802.1Qbh · 0472f39f
      Eric Blake 提交于
      Detected by Coverity.  Leak present since commit ca3b22bb.
      
      * src/util/macvtap.c (doPortProfileOp8021Qbh): Release device name.
      0472f39f
    • E
      qemu: plug memory leak on migration · 16e7b5fa
      Eric Blake 提交于
      Detected by Coverity.  Leak introduced in commit 72de0d28.
      
      * src/qemu/qemu_migration.c (qemuMigrationCookieGraphicsXMLParse):
      Clean up on success.
      16e7b5fa
    • E
      conf: plug memory leak on error · 5fa3d775
      Eric Blake 提交于
      Detected by Coverity.  Leak present since commit 874e65aa; and
      while commit d50bb45b tried to fix the issue, it missed a path.
      
      * src/conf/domain_conf.c (virDomainDefParseBootXML): Always clean
      up useserial.
      5fa3d775
    • G
      Use virBufferEscapeShell in virNetSocketNewConnectSSH · 6ac6238d
      Guido Günther 提交于
      to escape the netcat command since it's passed to the shell. Adjust
      expected test case output accordingly.
      6ac6238d
    • G
      Add virBufferEscapeShell · 920487b3
      Guido Günther 提交于
      Escape strings so they're safe to pass to the shell. It's based on
      virsh's cmdEcho.
      920487b3
    • G
    • E
      storage: plug memory leak on error · 8f8258e1
      Eric Blake 提交于
      Detected by Coverity.  Present since commit 82c1740a.
      
      * src/storage/storage_backend_logical.c
      (virStorageBackendLogicalMakeVol): Fix leak.
      8f8258e1
    • J
      util: Make getaddrinfo failure nonfatal in virGetHostname · f1409fa7
      Jiri Denemark 提交于
      Setting a hostname that cannot be resolved is not the best configuration
      but since virGetHostname only calls getaddrinfo to get host's canonical
      name and we do not fail if the returned canonical name is NULL or
      "localhost", there is no reason why we should fail if getaddrinfo itself
      fails.
      f1409fa7
    • J
      qemu: Make sure BeginJob is always followed by EndJob · bf7676af
      Jiri Denemark 提交于
      Otherwise we can end up with a dangling job that can only be cleared by
      restarting libvirtd.
      bf7676af
    • J
      qemu: Log debug messages when changing job · dddbfcf6
      Jiri Denemark 提交于
      Log debug messages anytime we call *BeginJob* or *EndJob* so that it's
      easier to spot incorrect usage of domain job APIs.
      dddbfcf6
    • E
      qemu: fix text block info parsing · f043ff63
      Eric Blake 提交于
      Detected by Coverity.  p (the pointer to the string) is always true;
      when in reality, we wanted to know whether the integer value of the
      just-parsed string is '0' or '1'.  Logic bug since commit b1b5b51a.
      
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextGetBlockInfo): Set
      results to proper value.
      f043ff63
    • E
      qemu: avoid text monitor null deref · 60be9e8c
      Eric Blake 提交于
      Detected by Coverity.  If, for some reason, our text monitor input
      does not match our assumptions, we end up incrementing p while it
      is NULL, then dereferencing the pointer 0x1, which will fault.
      
      * src/qemu/qemu_monitor_text.c
      (qemuMonitorTextGetBlockStatsParamsNumber): Rewrite to avoid
      deref of strchr failure.  Fix indentation.
      60be9e8c
    • E
      qemu: check for json allocation failure · ce521f24
      Eric Blake 提交于
      Detected by Coverity.  Introduced in commit b1b5b51a.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockInfo):
      Avoid null dereference.
      ce521f24
    • E
      build: add compiler attributes to virUUIDParse · 430156cf
      Eric Blake 提交于
      Coverity complained that most, but not all, clients of virUUIDParse
      were checking for errors.  Silence those coverity warnings by
      explicitly marking the cases where we trust the input, and fixing
      one instance that really should have been checking.  In particular,
      this silences a rather large percentage of the warnings I saw on my
      most recent Coverity analysis run.
      
      * src/util/uuid.h (virUUIDParse): Enforce rules.
      * src/util/uuid.c (virUUIDParse): Drop impossible check; at least
      Coverity will detect if we break rules and pass NULL.
      * src/xenapi/xenapi_driver.c (xenapiDomainCreateXML)
      (xenapiDomainLookupByID, xenapiDomainLookupByName)
      (xenapiDomainDefineXML): Ignore return when we trust data source.
      * src/vbox/vbox_tmpl.c (nsIDtoChar, vboxIIDToUUID_v3_x)
      (vboxCallbackOnMachineStateChange)
      (vboxCallbackOnMachineRegistered, vboxStoragePoolLookupByName):
      Likewise.
      * src/node_device/node_device_hal.c (gather_system_cap): Likewise.
      * src/xenxs/xen_sxpr.c (xenParseSxpr): Check for errors.
      430156cf
    • M
      virFDStream: close also given errfd (fd leak) · 72851bb9
      Marc-André Lureau 提交于
      In virFDStreamOpenFileInternal(), a errfd pipe is opened by
      virCommandRunAsync() and given to virFDStreamOpenInternal().
      
      It seems virFDStream should close errfd, just like the other
      fd it is given.
      
      This fixes screenshots leaking FDs:
      http://bugzilla.redhat.com/show_bug.cgi?id=745761
      72851bb9
    • E
      command: avoid fd leak on failure · 219600c9
      Eric Blake 提交于
      virCommandTransferFD promises that the fd is no longer owned by
      the caller.  Normally, we want the fd to remain open until the
      child runs, but in error situations, we must close it earlier.
      
      * src/util/command.c (virCommandTransferFD): Close fd now if we
      can't track it to close later.
      (virCommandKeepFD): Adjust helper to make this easier.
      219600c9
  3. 13 10月, 2011 11 次提交
    • S
      Fix typo in lxc_controller · d60299c3
      Serge E. Hallyn 提交于
      s/Mouting/Mounting.
      Signed-off-by: NSerge Hallyn <serge.hallyn@canonical.com>
      d60299c3
    • M
      qemu: Check for domain being active on successful job acquire · 9bc9999b
      Michal Privoznik 提交于
      As this is needed. Although some functions check for domain
      being active before obtaining job, we need to check it after,
      because obtaining job unlocks domain object, during which
      a state of domain can be changed.
      9bc9999b
    • M
      events: Propose a separate lock for event queue · d81eee40
      Michal Privoznik 提交于
      Currently, push & pop from event queue (both server & client side)
      rely on lock from higher levels, e.g. on driver lock (qemu),
      private_data (remote), ...; This alone is not sufficient as not
      every function that interacts with this queue can/does lock,
      esp. in client where we have a different approach, "passing
      the buck".
      
      Therefore we need a separate lock just to protect event queue.
      
      For more info see:
      https://bugzilla.redhat.com/show_bug.cgi?id=743817
      d81eee40
    • M
      qemu: Implement VIR_DUMP_RESET · 2050b61d
      Michal Privoznik 提交于
      This patch extends qemudDomainCoreDump so it supports new VIR_DUMP_RESET
      flag. If this flag is set, domain is reset on successful dump. However,
      this is needed to be done after we start CPUs.
      2050b61d
    • M
      virDomainCoreDump: Introduce VIR_DUMP_RESET flag · 4dadfe59
      Michal Privoznik 提交于
      This flag is intended to allow user to do so called system reset
      after dump, instead of sending ACPI reboot event.
      4dadfe59
    • E
      snapshot: implement LIST_LEAVES flag in qemu · 5cf56c4b
      Eric Blake 提交于
      With the recent refactoring of qemu snapshot relationships, it
      is now trivial to filter on leaves.
      
      * src/conf/domain_conf.c (virDomainSnapshotObjListCount)
      (virDomainSnapshotObjListCopyNames): Handle new flag.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotListNames)
      (qemuDomainSnapshotNum, qemuDomainSnapshotListChildrenNames)
      (qemuDomainSnapshotNumChildren): Pass new flag through.
      5cf56c4b
    • E
      snapshot: add API for filtering by leaves · 8b6d1a20
      Eric Blake 提交于
      Counterpart to --roots.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_SNAPSHOT_LIST_LEAVES):
      New flag.
      * src/libvirt.c (virDomainSnapshotNum, virDomainSnapshotListNames)
      (virDomainSnapshotNumChildren)
      (virDomainSnapshotListChildrenNames): Document it.
      * tools/virsh.c (cmdSnapshotList): Expose it.
      * tools/virsh.pod (snapshot-list): Document --leaves.
      8b6d1a20
    • P
      xen: Return tap2 for tap2 disks · c490b469
      Philipp Hahn 提交于
      For some versions of Xen the difference between "tap" and "tap2" is
      important. When converting back from xen-sxpr to libvirt-xml, that
      information is lost, which breaks re-defining the domain using that
      data.
      
      Explicitly return "tap2" for disks defined as "device/tap2".
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      c490b469
    • P
      xen: fix PyGrub boot device order · c2969ec7
      Philipp Hahn 提交于
      When PyGrub is used as the bootloader in Xen, it gets passed the first
      bootable disk. Xend supports a "bootable"-flag for this, which isn't
      explicitly supported by libvirt.
      When converting libvirt-xml to xen-sxpr the "bootable"-flag gets
      implicitly set by xen.xend.XenConfig.device_add() for the first disk
      (marked as "Compat hack -- mark first disk bootable").
      When converting back xen-sxpr to libvirt-xml, the disks are returned in
      the internal order used by Xend ignoring the "bootable"-flag, which
      loses the original order. When the domain is then re-defined, the order
      of disks is changed, which breaks PyGrub, since a different disk gets
      passed.
      
      When converting xen-sxpr to libvirt-xml, use the "bootable"-flag to
      determine the first disk.
      
      This isn't perfect, since several disks can be marked as bootable using
      the Xend-API, but that is not supported by libvirt. In all known cases
      relevant to libvirt exactly one disk is marked as bootable.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      c2969ec7
    • H
      Introduce <driver> under <filesystem> to support open-by-handle · da8127e6
      Harsh Prateek Bora 提交于
      VirtFS allows the user to choose between path/handle based fs driver.
      As of now, libvirt hardcoded path based driver only. This patch provides
      a solution to allow user to choose between path/handle based fs driver.
      
      Sample:
      
          <filesystem type='mount'>
            <driver type='handle'/>
            <source dir='/folder/to/share1'/>
            <target dir='mount_tag1'/>
          </filesystem>
      
          <filesystem type='mount'>
            <driver type='path'/>
            <source dir='/folder/to/share2'/>
            <target dir='mount_tag2'/>
          </filesystem>
      Signed-off-by: NHarsh Prateek Bora <harsh@linux.vnet.ibm.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      da8127e6
    • S
      buf: implement generic virBufferEscape · 7f197559
      Sage Weil 提交于
      Implement a generic helper to escape a given set of characters with a
      leading '\'.  Generalizes virBufferEscapeSexpr().
      Signed-off-by: NSage Weil <sage@newdream.net>
      7f197559
  4. 12 10月, 2011 8 次提交
    • E
      snapshot: drop dead parameters · ebec21ee
      Eric Blake 提交于
      The previous optimizations lead to some follow-on cleanups.
      
      * src/conf/domain_conf.c (virDomainSnapshotForEachChild)
      (virDomainSnapshotForEachDescendant): Drop dead parameter.
      (virDomainSnapshotActOnDescendant)
      (virDomainSnapshotObjListNumFrom)
      (virDomainSnapshotObjListGetNamesFrom): Update callers.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotNumChildren)
      (qemuDomainSnapshotListChildrenNames, qemuDomainSnapshotDelete):
      Likewise.
      * src/conf/domain_conf.h: Update prototypes.
      ebec21ee
    • E
      snapshot: take advantage of new relations · 35abced2
      Eric Blake 提交于
      Among other improvements, virDomainSnapshotForEachDescendant is
      changed from iterative O(n^2) to recursive O(n).  A bit better
      than the O(n^3) implementation in virsh snapshot-list!
      
      * src/conf/domain_conf.c (virDomainSnapshotObjListNum)
      (virDomainSnapshotObjListNumFrom)
      (virDomainSnapshotObjeListGetNames, virDomainSnapshotForEachChild)
      (virDomainSnapshotForEachDescendant): Optimize.
      (virDomainSnapshotActOnDescendant): Tweak.
      (virDomainSnapshotActOnChild, virDomainSnapshotMarkDescendant):
      Delete, now that they are unused.
      35abced2
    • E
      snapshot: track qemu snapshot relations · 9279bdf7
      Eric Blake 提交于
      Maintain the parent/child relationships of all qemu snapshots.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotLoad): Populate
      relationships after loading.
      (qemuDomainSnapshotCreateXML): Set relations on creation; tweak
      redefinition to reuse existing object.
      (qemuDomainSnapshotReparentChildren, qemuDomainSnapshotDelete):
      Clear relations on delete.
      9279bdf7
    • E
      snapshot: framework for more efficient relation traversal · 7ec6f7bd
      Eric Blake 提交于
      No one was using virDomainSnapshotHasChildren, but that was an
      O(n) function.  Exposing and tracking a bit more metadata for each
      snapshot will allow the same query to be made with an O(1) query
      of the member field.  For single snapshot operations (create,
      delete), callers can be trusted to maintain the metadata themselves,
      but for reloading, we can't compute parents as we go since there
      is no guarantee that parents were parsed before children, so we also
      provide a function to refresh the relationships, and which can
      be used to detect if the user has ignored our warnings and been
      directly modifying files in /var/lib/libvirt/qemu/snapshot.  This
      patch only adds metadata; later patches will actually use it.
      
      This layout intentionally hardcodes the size of each snapshot struct,
      by tracking sibling pointers, rather than having to deal with the
      headache of yet more memory management by directly sticking a
      dynamically sized child[] on each parent.
      
      * src/conf/domain_conf.h (_virDomainSnapshotObj)
      (_virDomainSnapshotObjList): Add members.
      (virDomainSnapshotUpdateRelations, virDomainSnapshotDropParent):
      New prototypes.
      (virDomainSnapshotHasChildren): Delete.
      * src/conf/domain_conf.c (virDomainSnapshotSetRelations)
      (virDomainSnapshotUpdateRelations, virDomainSnapshotDropParent):
      New functions.
      (virDomainSnapshotHasChildren): Drop unused function.
      * src/libvirt_private.syms (domain_conf): Update exports.
      7ec6f7bd
    • E
      snapshot: use correct qmp monitor command · 59f179ce
      Eric Blake 提交于
      To date, JSON disk snapshots worked by accident, as they were always
      using hmp fallback due to a typo in commit e702b5ba not picking up
      on the (intentional) difference in command names between the two
      monitor protocols.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskSnapshot):
      Spell QMP command correctly.
      Reported by Luiz Capitulino.
      59f179ce
    • E
      build: fix mingw build without sasl · 83ad88b7
      Eric Blake 提交于
      Detected by autogen.sh on a cross-mingw build:
      
      Creating library file: .libs/libvirt.dll.a
      Cannot export virNetSASLContextCheckIdentity: symbol not defined
      Cannot export virNetSASLContextNewServer: symbol not defined
      ...
      
      * src/libvirt_private.syms (virnetsaslcontext.h): Move symbols...
      * src/libvirt_sasl.syms: ...to new file.
      * src/Makefile.am (USED_SYM_FILES) [HAVE_SASL]: Use new file.
      (EXTRA_DIST): Ship it.
      83ad88b7
    • E
      build: fix 'make distcheck' · c654ba88
      Eric Blake 提交于
      I got these distcheck failures with sanlock enabled:
      
      ERROR: files left in build directory after distclean:
      ./tools/virt-sanlock-cleanup
      ./src/locking/qemu-sanlock.conf
      
      * src/Makefile.am (DISTCLEANFILES) [HAVE_SANLOCK]: Clean built
      file.
      * tools/Makefile.am (DISTCLEANFILES): Likewise.
      c654ba88
    • E
      build: ship helper scripts · e648aee0
      Eric Blake 提交于
      Otherwise, 'make rpm' fails with:
      
        GEN    libvirt_qemu.def
      make[2]: *** No rule to make target `dtrace2systemtap.pl', needed by `libvirt_probes.stp'.  Stop.
      
      * src/Makefile.am (EXTRA_DIST): Add recent script additions.
      e648aee0