1. 20 11月, 2012 1 次提交
    • E
      snapshot: implement new filter sets · 62711817
      Eric Blake 提交于
      Relatively straight-forward.  And since qemu was already using
      VIR_DOMAIN_SNAPSHOT_FILTERS_ALL, with 6 different APIs all calling
      into this common code, I've instantly added all 5 flags to 6 APIs.
      
      * src/conf/snapshot_conf.h (VIR_DOMAIN_SNAPSHOT_FILTERS_ALL):
      Enable new filters.
      * src/conf/snapshot_conf.c (virDomainSnapshotObjListGetNames):
      Prep the new flags.
      (virDomainSnapshotObjListCopyNames): Actually do the filtering.
      62711817
  2. 19 11月, 2012 1 次提交
    • E
      snapshot: add two more filter sets to API · e9028f4b
      Eric Blake 提交于
      As we enable more modes of snapshot creation, it becomes more important
      to be able to quickly filter based on snapshot properties.  This patch
      introduces new filter flags; subsequent patches will introduce virsh
      back-compat filtering, as well as actual libvirt filtering.
      
      * include/libvirt/libvirt.h.in (virDomainSnapshotListFlags): Add
      five new flags in two new groups.
      * src/libvirt.c (virDomainSnapshotNum, virDomainSnapshotListNames)
      (virDomainListAllSnapshots, virDomainSnapshotNumChildren)
      (virDomainSnapshotListChildrenNames)
      (virDomainSnapshotListAllChildren): Document them.
      * src/conf/snapshot_conf.h (VIR_DOMAIN_SNAPSHOT_FILTERS_STATUS)
      (VIR_DOMAIN_SNAPSHOT_FILTERS_LOCATION): Add new convenience filter
      collection macros.
      * tools/virsh-snapshot.c (cmdSnapshotList): Add 5 new flags.
      * tools/virsh.pod (snapshot-list): Document them.
      e9028f4b
  3. 17 11月, 2012 3 次提交
    • L
      qemu: allow larger discrepency between memory & currentMemory in domain xml · 89204fca
      Laine Stump 提交于
      This resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=873134
      
      The reported problem is that an attempt to restore a saved domain that
      was configured with <currentMemory> and <memory> set to some (same for
      both) number that's not a multiple of 4096KiB results in an error like
      this:
      
        error: Failed to start domain libvirt_test_api
        error: XML error: current memory '4001792k' exceeds maximum '4000768k'
      
      (in this case, currentMemory was set to 4000000KiB).
      
      The reason for this failure is:
      
      1) a saved image contains the "live xml" of the domain at the time of
      the save.
      
      2) the live xml of a running domain gets its currentMemory
      (a.k.a. cur_balloon) directly from the qemu monitor rather than from
      the configuration of the domain.
      
      3) the value reported by qemu is (sometimes) not exactly what was
      originally given to qemu when the domain was started, but is rounded
      up to [some indeterminate granularity] - in some versions of qemu that
      granularity is apparently 1MiB, and in others it is 4MiB.
      
      4) When the XML is parsed to setup the state of the restored domain,
      the XML parser for <currentMemory> compares it to <memory> (which is
      the maximum allowed memory size for the domain) and if <currentMemory>
      is greater than the next 1024KiB boundary above <memory>, it spits out
      an error and fails.
      
      For example (from the BZ) if you start qemu on RHEL6 with both
      <currentMemory> and <memory> of 4000000 (this number is in KiB),
      libvirt's dominfo or dumpxml will report "4001792" back (rounded up to
      next 4MiB) for 10-20 seconds after the start, then revert to reporting
      "4000000". On Fedora 16 (which uses qemu-1.0), it will instead report
      "4000768" (rounded up to next 1MiB). On Fedora 17 (qemu-1.2), it seems
      to always report "4000000". ("4000000" is of course okay, and
      "4000768" is also okay since that's the next 1024KiB boundary above
      "4000000" and the parser was already allowing for that. But "4001792
      is *not* okay and produces the error message.)
      
      This patch solves the problem by changing the allowed "fudge factor"
      when parsing from 1024KiB to 4096KiB to match the maximum up-rounding
      that could be done in qemu.
      
      (I had earlier thought to fix this by up-rounding <memory> in the
      dumpxml that's put into the saved image, but that wouldn't have fixed
      the case where the save image was produced by an "unfixed"
      libvirtd.)
      89204fca
    • E
      nodeinfo: port nodecpumap to RHEL5 · 9504ae5b
      Eric Blake 提交于
      Prior to this patch, 'virsh nodecpumap' on older kernels reported:
      error: Unable to get cpu map
      error: out of memory
      
      * src/nodeinfo.c (linuxParseCPUmax): Don't overwrite error.
      (nodeGetCPUBitmap): Provide backup implementation.
      9504ae5b
    • E
      nodeinfo: support kernels that lack socket information · 47976b48
      Eric Blake 提交于
      On RHEL 5, I was getting a segfault trying to start libvirtd,
      because we were failing virNodeParseSocket but not checking
      for errors, and then calling CPU_SET(-1, &sock_map) as a result.
      But if you don't have a topology/physical_package_id file,
      then you can just assume that the cpu belongs to socket 0.
      
      * src/nodeinfo.c (virNodeGetCpuValue): Change bool into
      default_value.
      (virNodeParseSocket): Allow for default value when file is missing,
      different from fatal error on reading file.
      (virNodeParseNode): Update call sites to fail on error.
      47976b48
  4. 16 11月, 2012 3 次提交
    • E
      snapshot: require user to supply external memory file name · 516c1223
      Eric Blake 提交于
      For disk snapshots, the user could request an external snapshot
      but not supply a filename; later on, we would check this condition
      and generate a suitable name if possible, or gracefully error out
      when not possible (such as when the original file was a block
      device).  But unless we come up with a suitable way to generate
      external memory file names, we have no later code point that was
      checking for NULL, so we should forbid this up front.
      
      * src/conf/snapshot_conf.c (virDomainSnapshotDefParseString):
      Avoid NULL deref, since we don't generate names yet.
      516c1223
    • L
      qemu: Beautify code indent in migration codes · 63158d58
      liguang 提交于
      Signed-off-by: Nliguang <lig.fnst@cn.fujitsu.com>
      63158d58
    • M
      sanlock: Retry after EINPROGRESS · 96a02703
      Michal Privoznik 提交于
      It may take some time for sanlock to add a lockspace. And if user
      restart libvirtd service meanwhile, the fresh daemon can fail adding
      the same lockspace with EINPROGRESS. Recent sanlock has
      sanlock_inq_lockspace() function which should block until lockspace
      changes state. If we are building against older sanlock we should
      retry a few times before claiming an error. This issue can be easily
      reproduced:
      
      for i in {1..1000} ; do echo $i; service libvirtd restart; sleep 2; done
      20
      Stopping libvirtd daemon:                                  [FAILED]
      Starting libvirtd daemon:                                  [  OK  ]
      21
      Stopping libvirtd daemon:                                  [  OK  ]
      Starting libvirtd daemon:                                  [  OK  ]
      22
      Stopping libvirtd daemon:                                  [  OK  ]
      Starting libvirtd daemon:                                  [  OK  ]
      
       error : virLockManagerSanlockSetupLockspace:334 : Unable to add
       lockspace /var/lib/libvirt/sanlock/__LIBVIRT__DISKS__: Operation now in
       progress
      96a02703
  5. 15 11月, 2012 7 次提交
    • V
      qemu, lxc: Change host CPU number detection logic. · a2b3d7cf
      Viktor Mihajlovski 提交于
      The drivers for QEMU and LXC use virNodeGetInfo only to determine
      the number of host CPUs. On Linux hosts nodeGetCPUCount has less
      overhead.
      a2b3d7cf
    • V
      nodeinfo: enable nodeGetCPUCount for older kernels · 0c996c10
      Viktor Mihajlovski 提交于
      Since /sys/devices/system/cpu/present is not available on
      older kernels like on RHEL 5.x nodeGetCPUCount will
      fail there. The fallback implemented is to scan for
      /sys/devices/system/cpu/cpuNN entries.
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      0c996c10
    • M
      Use helper functions to format the journal iov array · 39c814ff
      Miloslav Trmač 提交于
      This simplifies the top-level code, at the cost of using a little more
      stack space.  The primary benefit is being able to send more fields
      without knowing in advance how many of them, and of which types, these
      fields will be, and without having to individually add buffer variables.
      
      The code imposes an upper limit on the total number of iovs/buffers
      used, and fields that wouldn't fit are silently dropped.  This is not
      significant in this patch, but will affect the following one.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      39c814ff
    • M
      Add metadata to virLogOutputFunc · 37f7a1fa
      Miloslav Trmač 提交于
      ... and update all users.  No change in functionality, the parameter
      will be used in the next patch.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      37f7a1fa
    • M
      Add a metadata parameter to virLog{, V}Message · c780e9b8
      Miloslav Trmač 提交于
      ... and update all users.  No change in functionality, the parameter
      will be used later.
      
      The metadata representation is as minimal as possible, but requires
      the caller to allocate an array on stack explicitly.
      
      The alternative of using varargs in the virLogMessage() callers:
      * Would not allow the caller to optionally omit some metadata elements,
        except by having two calls to virLogMessage.
      * Would not be as type-safe (e.g. using int vs. size_t), and the compiler
        wouldn't be able to do type checking
      * Depending on parameter order:
        a) virLogMessage(..., message format, message params...,
                         metadata..., NULL)
           can not be portably implemented (parse_printf_format() is a glibc
           function)
        b) virLogMessage(..., metadata..., NULL,
                         message format, message params...)
           would prevent usage of ATTRIBUTE_FMT_PRINTF and the associated
           compiler checking.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      c780e9b8
    • J
      qemu: add bootindex for usb-host and usb-redir devices · a4c19459
      Ján Tomko 提交于
      Allow bootindex to be specified for redirected USB devices and host USB
      devices.
      
      Bug: https://bugzilla.redhat.com/show_bug.cgi?id=805414
      a4c19459
    • L
      util: fix index when building lock owners array · bc4b4330
      Laine Stump 提交于
      The "restart" function for locks allocates a new array according to
      and pre-sets its length, then reads the owner pids from a JSON
      document in a loop. Rather than adding each owner at a different
      index, though, it repeatedly overwrites the last element of the array
      with all the owners.
      bc4b4330
  6. 14 11月, 2012 3 次提交
  7. 13 11月, 2012 1 次提交
    • P
      nodeinfo: Add check and workaround to guarantee valid cpu topologies · 9576afd1
      Peter Krempa 提交于
      Lately there were a few reports of the output of the virsh nodeinfo
      command being inaccurate. This patch tries to avoid that by checking if
      the topology actually makes sense. If it doesn't we then report a
      synthetic topology that indicates to the user that the host capabilities
      should be checked for the actual topology.
      9576afd1
  8. 12 11月, 2012 2 次提交
    • M
      AbortJob: Fix documentation · fd723164
      Michal Privoznik 提交于
      This API was never synchronous and probably doesn't even need to be.
      fd723164
    • M
      qemu: Allow migration to be cancelled at prepare phase · ab5e7d49
      Michal Privoznik 提交于
      Currently, if user calls virDomainAbortJob we just issue
      'migrate_cancel' and hope for the best. However, if user calls
      the API in wrong phase when migration hasn't been started yet
      (perform phase) the cancel request is just ignored. With this
      patch, the request is remembered and as soon as perform phase
      starts, migration is cancelled.
      ab5e7d49
  9. 10 11月, 2012 1 次提交
    • V
      capabilities: defaultConsoleTargetType can depend on architecture · b1c88c14
      Viktor Mihajlovski 提交于
      For S390, the default console target type cannot be of type 'serial'.
      It is necessary to at least interpret the 'arch' attribute
      value of the os/type element to produce the correct default type.
      
      Therefore we need to extend the signature of defaultConsoleTargetType
      to account for architecture. As a consequence all the drivers
      supporting this capability function must be updated.
      
      Despite the amount of changed files, the only change in behavior is
      that for S390 the default console target type will be 'virtio'.
      
      N.B.: A more future-proof approach could be to to use hypervisor
      specific capabilities to determine the best possible console type.
      For instance one could add an opaque private data pointer to the
      virCaps structure (in case of QEMU to hold capsCache) which could
      then be passed to the defaultConsoleTargetType callback to determine
      the console target type.
      Seems to be however a bit overengineered for the use case...
      Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
      b1c88c14
  10. 09 11月, 2012 2 次提交
    • P
      qemu: Fix domain ID numbering race condition · 02cf57c0
      Peter Krempa 提交于
      When the libvirt daemon is restarted it tries to reconnect to running
      qemu domains. Since commit d38897a5 the
      re-connection code runs in separate threads. In the original
      implementation the maximum of domain ID's (that is used as an
      initializer for numbering guests created next) while libvirt was
      reconnecting to the guest.
      
      With the threaded implementation this opens a possibility for race
      conditions with the thread that is autostarting guests. When there's a
      guest running with id 1 and the daemon is restarted. The autostart code
      is reached first and spawns the first guest that should be autostarted
      as id 1. This results into the following unwanted situation:
      
       # virsh list
         Id    Name                           State
        ----------------------------------------------------
         1     guest1                         running
         1     guest2                         running
      
      This patch extracts the detection code before the re-connection threads
      are started so that the maximum id of the guests being reconnected to is
      known.
      
      The only semantic change created by this is if the guest with greatest ID
      quits before we are able to reconnect it's ID is used anyway as the
      greatest one as without this patch the greatest ID of a process we could
      successfuly reconnect to would be used.
      02cf57c0
    • P
      storage: fix broken backing chain · e0c469e5
      Philipp Hahn 提交于
      82507838 refactored the code to keep both the raw and canonicalized form
      of the backingStore, which breaks badly when the storage pool contains a
      storage volume, which is missing its backing store file:
       # ./daemon/libvirtd -l
       2012-11-07 12:43:33.279+0000: 22175: info : libvirt version: 1.0.0
       2012-11-07 12:43:33.279+0000: 22175: error : absolutePathFromBaseFile:542 : Can't canonicalize path '/var/lib/libvirt/images/base.qcow2': No such file or directory
       2012-11-07 12:43:33.280+0000: 22175: error : storageDriverAutostart:115 : Failed to autostart storage pool 'default': Can't canonicalize path '/var/lib/libvirt/images/base.qcow2': No such file or directory
      
      This is because virStorageFileGetMetadataFromBuf() aborts with -1 if the
      filename of the backingStore can not be canonicalized:
       #0  absolutePathFromBaseFile () at util/storage_file.c:541
       #1  virStorageFileGetMetadataFromBuf () at util/storage_file.c:728
       #2  virStorageFileGetMetadataFromFD () at util/storage_file.c:932
       #3  virStorageBackendProbeTarget () at storage/storage_backend_fs.c:94
       #4  virStorageBackendFileSystemRefresh () at storage/storage_backend_fs.c:849
       #5  storagePoolStart () at storage/storage_driver.c:700
       #6  virStoragePoolCreate () at libvirt.c:12471
       ...
      
      Treat files which miss their backing file as standalone files.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      e0c469e5
  11. 08 11月, 2012 2 次提交
    • P
      qemu: Fix function header formating of 2 functions · e124f498
      Peter Krempa 提交于
      Headers of qemuDomainSnapshotLoad and qemuDomainNetsRestart were
      improperly formatted.
      e124f498
    • P
      snapshot: qemu: Add support for external inactive snapshots · 9b5a514b
      Peter Krempa 提交于
      This patch adds support for external disk snapshots of inactive domains.
      The snapshot is created by calling using qemu-img by calling:
      
       qemu-img create -f format_of_snapshot -o
       backing_file=/path/to/src,backing_fmt=format_of_backing_image
       /path/to/snapshot
      
      in case the backing image format is known or probing is allowed and
      otherwise:
      
       qemu-img create -f format_of_snapshot -o  backing_file=/path/to/src
       /path/to/snapshot
      
      on each of the disks selected for snapshotting. This patch also modifies
      the snapshot preparing function to support creating external snapshots
      and to sanitize arguments. For now the user isn't able to mix external
      and internal snapshots but this restriction might be lifted in the
      future.
      9b5a514b
  12. 07 11月, 2012 1 次提交
    • M
      qemu: Emit event if 'cont' fails · a08fc66d
      Michal Privoznik 提交于
      Some operations, APIs needs domain to be paused prior operation can be
      performed, e.g. (managed-) save of a domain. The processors should be
      restored in the end. However, if 'cont' fails for some reason, we log a
      message but this is not sufficient as an event should be emitted as
      well. Mgmt application can then decide what to do.
      a08fc66d
  13. 06 11月, 2012 4 次提交
    • P
      qemu: Don't corrupt pointer in qemuDomainSaveMemory() · fb58f8e2
      Peter Krempa 提交于
      The code that was split out into the qemuDomainSaveMemory expands the
      pointer containing the XML description of the domain that it gets from
      higher layers. If the pointer changes the old one is invalid and the
      upper layer function tries to free it causing an abort.
      
      This patch changes the expansion of the original string to a new
      allocation and copy of the contents.
      fb58f8e2
    • M
      esx: Yet another connection fix for 5.1 · 9c294e6f
      Martin Kletzander 提交于
      After the connection to ESX 5.1 being broken since g1e7cd395, the fix
      in bab7752c helped a bit, but still missed a spot, so the connection
      is now successful, but some APIs (for example defineXML) don't work.
      Two cases missing are added in this patch to avoid that.
      9c294e6f
    • M
      qemu: Add controllers in specified order · 0f720ab3
      Michal Privoznik 提交于
      qemu is sensitive to the order of arguments passed. Hence, if a
      device requires a controller, the controller cmd string must
      precede device cmd string. The same apply for controllers, when
      for instance ccid controller requires usb controller. So
      controllers create partial ordering in which they should be added
      to qemu cmd line.
      0f720ab3
    • M
      qemu: Wrap controllers code into dummy loop · 77b93dbc
      Michal Privoznik 提交于
      which just re-indent code and prepare it for next patch.
      77b93dbc
  14. 05 11月, 2012 2 次提交
  15. 04 11月, 2012 1 次提交
    • P
      snapshot: qemu: Add support for external checkpoints · f569b87f
      Peter Krempa 提交于
      This patch adds support to take external system checkpoints.
      
      The functionality is layered on top of the previous disk-only snapshot
      code. When the checkpoint is requested the domain memory is saved to the
      memory image file using migration to file. (The user may specify to
      take the memory image while the guest is live with the
      VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag.)
      
      The memory save image shares format with the image created by
      virDomainSave() API.
      f569b87f
  16. 03 11月, 2012 6 次提交
    • P
      snapshot: qemu: Rename qemuDomainSnapshotCreateActive · b5fd4044
      Peter Krempa 提交于
      Before now, libvirt supported only internal snapshots for active guests.
      This patch renames this function to qemuDomainSnapshotCreateActiveInternal
      to prepare the grounds for external active snapshots.
      b5fd4044
    • P
      snapshot: qemu: Add async job type for snapshots · 2a59a3d5
      Peter Krempa 提交于
      The new external system checkpoints will require an async job while the
      snapshot is taken. This patch adds QEMU_ASYNC_JOB_SNAPSHOT to track this
      job type.
      2a59a3d5
    • P
      snapshot: Add flag to enable creating checkpoints in live state · 5f75bd4b
      Peter Krempa 提交于
      The default behavior while creating external checkpoints is to pause the
      guest while the memory state is captured. We want the users to sacrifice
      space saving for creating the memory save image while the guest is live
      to minimize downtime.
      
      This patch adds a flag that causes the guest not to be paused before
      taking the snapshot.
       *include/libvirt/libvirt.h.in:
          - add new paused reason: VIR_DOMAIN_PAUSED_SNAPSHOT
          - add new flag for taking snapshot: VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
       *tools/virsh-domain-monitor.c:
          - add string representation for VIR_DOMAIN_PAUSED_SNAPSHOT
       *tools/virsh-snapshot.c:
          - add support for VIR_DOMAIN_SNAPSHOT_CREATE_LIVE
       *tools/virsh.pod:
          - add docs for --live option added to use
          VIR_DOMAIN_SNAPSHOT_CREATE_LIVE flag
      5f75bd4b
    • P
      qemu: Split out domain memory saving code to allow reuse · 2771f8b7
      Peter Krempa 提交于
      The code that saves domain memory by migration to file can be reused
      while doing external checkpoints of a machine. This patch extracts the
      common code and places it in a separate function.
      2771f8b7
    • P
      qemu: Clean up snapshot retrieval to use the new helper · ec69ca14
      Peter Krempa 提交于
      Two other places were left with the old code to look up snapshots.
      Change them to use the snapshot lookup helper.
      ec69ca14
    • P
      cpu: Add AMD Opteron G5 cpu model · d38b934c
      Peter Krempa 提交于
      d38b934c