1. 26 2月, 2014 2 次提交
    • E
      build: fix cgroups on non-Linux · fa2e4dbf
      Eric Blake 提交于
      Running ./autobuild.sh detected a mingw failure:
      
        CCLD     libvirt.la
      Cannot export virCgroupGetPercpuStats: symbol not defined
      Cannot export virCgroupSetOwner: symbol not defined
      
      * src/util/vircgroup.c (virCgroupGetPercpuStats)
      (virCgroupSetOwner): Implement stubs.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fa2e4dbf
    • J
      libxl: queue domain event earlier in shutdown handler · 4d975ded
      Jim Fehlig 提交于
      The shutdown handler may restart a domain when handling a reboot
      event or when <on_*> is set to 'restart'.  Restarting consists of
      calling libxlVmCleanup followed by libxlVmStart.  libxlVmStart will
      emit a VIR_DOMAIN_EVENT_STARTED event, but the SHUTDOWN event is
      not emitted until exiting the shutdown handler, after the STARTED
      event.
      
      This patch changes the logic a bit to queue the event at the start
      of the shutdown action, ensuring it is queued before any subsequent
      events that may be generated while executing the shutdown action.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      4d975ded
  2. 25 2月, 2014 18 次提交
    • L
      network: include plugged interface XML in "plugged" network hook · 2122cf39
      Laine Stump 提交于
      The network hook script gets called whenever an interface is plugged
      into or unplugged from a network, but even though the full XML of both
      the network and the domain is included, there is no reasonable way to
      determine what exact resources the plugged interface is using:
      
      1) Prior to a recent patch which modified the status XML of interfaces
      to include the information about actual hardware resources used, it
      would be possible to scan through the domain XML output sent to the
      hook, and from there find the correct interface, but that interface
      definition would not include any runtime info (e.g. bandwidth or vlan
      taken from a portgroup, or which physdev was used in case of a macvtap
      network).
      
      2) After the patch modifying the status XML of interfaces, the network
      name would no longer be included in the domain XML, so it would be
      completely impossible to determine which interface was the one being
      plugged.
      
      To solve that problem, this patch includes a single <interface>
      element at the beginning of the XML sent to the network hook for
      "plugged" and "unplugged" (just inside <hookData>) that is the status
      XML of the interface being plugged. This XML will include all info
      gathered from the chosen network and portgroup.
      
      NB: due to hardcoded spaces in all of the device *Format() functions,
      the <interface> element inside the <hookData> will be indented by 6
      spaces rather than 2. I had intended to fix this, but it turns out
      that to make virDomainNetDefFormat() indentation relative, I would
      have to do the same to virDomainDeviceInfoFormat(), and that function
      is called from 19 places - making that a prerequisite of this patch
      would cause too many merge difficulties if we needed to backport
      network hooks, so I chose to ignore the problem here and fix the
      problem for *all* devices in a followup later.
      2122cf39
    • L
      conf: output actual netdev status in <interface> XML · 7d5bf484
      Laine Stump 提交于
      Until now, the "live" XML status of an <interface type='network'>
      device would always show the network information, rather than the
      exact hardware device that was used. It would also show the name of
      any portgroup the interface belonged to, rather than providing the
      configuration that was derived from that portgroup. As an example,
      given the following network definition:
      
      [A]
        <network>
          <name>testnet</name>
          <forward type='bridge' dev='p4p1_0'>
            <interface dev='p4p1_0'/>
            <interface dev='p4p1_1'/>
            <interface dev='p4p1_2'/>
            <interface dev='p4p1_3'/>
          </forward>
          <portgroup name='admin'>
            <bandwidth>
                <inbound average='1000' peak='5000' burst='1024'/>
                <outbound average='128' peak='256' burst='256'/>
            </bandwidth>
          </portgroup>
        </network>
      
      and the following domain <interface>:
      
      [B]
        <interface type='network'>
          <source network='testnet' portgroup='admin'/>
        </interface>
      
      the output of "virsh dumpxml $domain" while the domain was running
      would yield something like this:
      
      [C]
        <interface type='network'>
          <source network='testnet' portgroup='admin'/>
          <target dev='macvtap0'/>
          <alias name='net0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
      
      In order to learn the exact bandwidth information of the interface, a
      management application would need to retrieve the XML for testnet,
      then search for the portgroup named "admin". Even worse, there was no
      simple and standard way to learn which host physdev the macvtap0
      device is attached to.
      
      Internally, libvirt has always kept this information in the
      virDomainDef that is held in memory, as well as storing it in the
      (libvirt-internal-only) domain status XML (in
      /var/run/libvirt/qemu/$domain.xml). In order to not confuse the runtime
      "actual state" with the config of the device, it's internally stored
      like this:
      
      [D]
        <interface type='network'>
          <source network='testnet' portgroup='admin'/>
          <actual type='direct'>
            <source dev='p4p1_0' mode='bridge'/>
            <bandwidth>
                <inbound average='1000' peak='5000' burst='1024'/>
                <outbound average='128' peak='256' burst='256'/>
            </bandwidth>
          </actual>
          <target dev='macvtap0'/>
          <alias name='net0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
      
      This was never exposed outside of libvirt though, because I thought it
      would be too awkward for a management application to need to look in
      two places for the same information, but I also wasn't sure that it
      would be okay to overwrite the config info (in this case "<source
      network='testnet' portgroup='admin'/>") with the actual runtime info
      (everything inside <actual> above).
      
      Now we have a need for this information to be made available to
      management applications (in particular, so that a network "plugged"
      hook will have full information about the device that is being plugged
      in), so it's time to take the leap and decide that it is acceptable
      for the config info to be replaced with actual runtime state (but
      *only* when reporting domain live status, *not* when saving state in
      /var/run/libvirt/qemu/$domain.xml - that remains the same so that
      there is no loss of information). That is what this patch does - once
      applied, the output of "virsh dumpxml $domain" when the domain is
      running will contain something like this:
      
      [E]
        <interface type='direct'>
          <source dev='p4p1_0' mode='bridge'/>
          <bandwidth>
              <inbound average='1000' peak='5000' burst='1024'/>
              <outbound average='128' peak='256' burst='256'/>
          </bandwidth>
          <target dev='macvtap0'/>
          <alias name='net0'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
      
      In effect, everything that is internally stored within <actual> is
      moved up a level to where a management application will expect
      it. This means that the management application will only look in a
      single place to learn - the type of interface in use, the name of the
      physdev (if relevant), the <bandwidth>, <vlan>, and <virtualport>
      settings in use.
      
      The potential downside is that a management app looking at this output
      will not see that the physdev 'p4p1_0' was actually allocated from the
      network named 'testnet', or that the bandwidth numbers were taken from
      the portgroup 'admin'. However, if they are interested in that info,
      they can always get the "inactive" XML for the domain.
      
      An example of where this could cause problems is in virt-manager's
      network device display, which shows the status of the device, but
      allows you to edit that status info and save it as the new
      config. Previously virt-manager would always display the information
      in example [C] above, and allow editing that. With this patch, it will
      instead display what is in [E] and allow editing it directly, which
      could lead to some confusion. I would suggest that virt-manager have
      an "edit" button which would change the display from the "live" xml to
      the "inactive" xml, so that editing would be done on that; such a
      change would both handle the new situation, and also be compatible
      with older releases.
      7d5bf484
    • L
      conf: new function virDomainActualNetDefContentsFormat · 9da98aa5
      Laine Stump 提交于
      This function is currently only called from one place, but in a
      subsequent patch will be called from a 2nd place.
      
      The new function exactly replicates the original behavior of the part
      of virDomainActualNetDefFormat() that it replaces, but takes a
      virDomainNetDefPtr instead of virDomainActualNetDefPtr, and uses the
      virDomainNetGetActual*() functions whenever possible, rather than
      reaching into def->data.network.actual - this is to be sure that we
      are reporting exactly what is being used internally, just in case
      there are any discrepancies (there shouldn't be).
      9da98aa5
    • L
      conf: re-situate <bandwidth> element in <interface> · 65487c0f
      Laine Stump 提交于
      This moves the call to virNetDevBandwidthFormat() in
      virDomainNetDefFormat() to be called right after the call to
      virNetDevVPortProfileFormat(), so that a single chunk of that function
      can be placed inside an if that conditionally calls
      virDomainActualNetDefContentsFormat() instead (next patch). The
      re-ordering necessitates modifying a couple of test data files.
      65487c0f
    • L
      conf: make virDomainNetDefFormat a public function · 7c39214c
      Laine Stump 提交于
      We will need to call virDomainNetDefFormat() from the network hook (in
      the network driver).
      7c39214c
    • L
      conf: handle null pointer in virNetDevVlanFormat · 79358733
      Laine Stump 提交于
      Other *Format() functions (e.g. virNetDevBandwidthFormat()) return
      with no action when called with a NULL *Def pointer. This makes
      virNetDevVlanFormat() consistent with that behavior.
      79358733
    • L
      conf: clarify what is returned for actual bandwidth and vlan · 6d4ffae4
      Laine Stump 提交于
      In practice, if a virDomainNetDef has a virDomainActualNetDef
      allocated, the ActualNetDef will *always* contain the bandwidth and
      vlan data from the NetDef (unless there was also a portgroup involved
      - see networkAllocateActualDevice()).
      
      However, virDomainNetGetActual(Bandwidth|Vlan)() were coded to make it
      appear as if it might be possible to have a valid bandwidth/vlan in
      the NetDef, but a NULL in the ActualNetDef. Believing this un-truth
      could lead to writing unnecessarily defensive code when dealing with
      the virDomainGetActual*() functions, so this patch makes it more
      obvious:
      
         If there is an ActualNetDef, it will always have a copy of the
         various appropriate bits from its parent NetDef, and the
         virDomainGetActual* function will *always* return the data from the
         ActualNetDef, not from the NetDef.
      
      The reason for this effective-NOP patch is that a subsequent patch to
      change virDomainNetDefFormat will rely on the above rule.
      6d4ffae4
    • W
      rbd: Set timeout options for librados · 60f70542
      Wido den Hollander 提交于
      These timeout values make librados/librbd return -ETIMEDOUT when a
      operation is blocking due to a failing/unreachable Ceph cluster.
      
      By having the operations time out libvirt will not block.
      60f70542
    • W
      rbd: Include return statuses from librados/librbd in logging · 761491eb
      Wido den Hollander 提交于
      With this information it's easier for the user to debug what is
      going wrong.
      761491eb
    • J
      virsh: mark CPU usage field names as translatable · 723e2f84
      Ján Tomko 提交于
      My commit ac758012 removed the translation markers when
      moving the field names into an array.
      723e2f84
    • C
      virsh: initialize str to NULL to solve a build issue · 7a8d7af6
      Chen Hanxiao 提交于
      Fix a -Werror=maybe-uninitialized issue.
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      7a8d7af6
    • E
      virsh: kill over-engineered asprintf failure recovery · 50f7960d
      Eric Blake 提交于
      I noticed this while shortening switch statements via VIR_ENUM.
      Basically, the only ways virAsprintf can fail are if we pass a
      bogus format string (but we're not THAT bad) or if we run out
      of memory (but it already warns on our behalf in that case).
      Throw away the cruft that tries too hard to diagnose a printf
      failure.
      
      * tools/virsh-volume.c (cmdVolList): Simplify.
      * tools/virsh-pool.c (cmdPoolList): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      50f7960d
    • E
      virsh: use more compact VIR_ENUM_IMPL · 466b12ab
      Eric Blake 提交于
      Dan Berrange suggested that using VIR_ENUM_IMPL is more compact
      than open-coding switch statements, and still just as forceful
      at making us remember to update lists if we add enum values
      in the future.  Make this change throughout virsh.
      
      Sure enough, doing this change caught that we missed at least
      VIR_STORAGE_VOL_NETDIR.
      
      * tools/virsh-domain-monitor.c (vshDomainIOErrorToString)
      (vshDomainControlStateToString, vshDomainStateToString)
      (vshDomainStateReasonToString): Change switch to enum lookup.
      (cmdDomControl, cmdDominfo): Update caller.
      * tools/virsh-domain.c (vshDomainVcpuStateToString)
      (vshDomainEventToString, vshDomainEventDetailToString): Change
      switch to enum lookup.
      (vshDomainBlockJobToString, vshDomainJobToString): New functions.
      (cmdVcpuinfo, cmdBlockJob, cmdDomjobinfo, cmdEvent): Update
      callers.
      * tools/virsh-network.c (vshNetworkEventToString): Change switch
      to enum lookup.
      * tools/virsh-pool.c (vshStoragePoolStateToString): New function.
      (cmdPoolList, cmdPoolInfo): Update callers.
      * tools/virsh-volume.c (vshVolumeTypeToString): Change switch to
      enum lookup.
      (cmdVolInfo, cmdVolList): Update callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      466b12ab
    • J
      Document the keyboard as a valid input type · 19845402
      Ján Tomko 提交于
      Commit bc183733 added a new input type, but didn't change the
      documentation.
      19845402
    • J
      virsh: Don't leak buffer if GetFDs fails in cmdCreate · fe1b6e72
      Ján Tomko 提交于
      Change the logic of the function to return false by default
      and move the freeing of the buffer to the cleanup section.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1067338
      fe1b6e72
    • J
      libxl: handle on_crash coredump actions · cfad607b
      Jim Fehlig 提交于
      Add support for coredump-{destroy,restart} actions of <on_crash> event.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      cfad607b
    • J
      libxl: add dump dir to libxlDriverConfig object · c2de456e
      Jim Fehlig 提交于
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      c2de456e
    • J
      libxl: honor domain lifecycle event configuration · 51b9b391
      Jim Fehlig 提交于
      The libxl driver was ignoring the <on_*> domain event configuration,
      causing e.g. a domain to be rebooted even when on_reboot is set to
      destroy.
      
      This patch honors the <on_*> configuration in the shutdown event
      handler.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      51b9b391
  3. 24 2月, 2014 7 次提交
  4. 22 2月, 2014 2 次提交
  5. 21 2月, 2014 11 次提交
    • J
      Ignore additional fields in iscsiadm output · 57e17a74
      Ján Tomko 提交于
      There has been a new field introduced in iscsiadm --mode session
      output [1], but our regex only expects four fields. This breaks
      startup of iscsi pools:
      error: Failed to start pool iscsi
      error: internal error: cannot find session
      
      Fix this by ignoring anything after the fourth field.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1067173
      
      [1] https://github.com/mikechristie/open-iscsi/commit/181af9a
      57e17a74
    • J
      Add a stub for virCgroupGetDomainTotalCpuStats · abf1daf0
      Ján Tomko 提交于
      Commit 65158899 broke the build on FreeBSD:
      In function `qemuDomainGetCPUStats':
      /../../src/qemu/qemu_driver.c:16102:
      undefined reference to `virCgroupGetDomainTotalCpuStats'
      abf1daf0
    • E
      maint: update to latest gnulib · 96d947ce
      Eric Blake 提交于
      Among other things, gnulib now allows overriding of sed during
      'make syntax-check'.
      
      * .gnulib: Update to latest, for maint.mk improvements.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      96d947ce
    • E
      virsh: add net-event command · de87691f
      Eric Blake 提交于
      Add 'virsh net-event --list' and 'virsh net-event [net] --event=name
      [--loop] [--timeout]'.  Very similar to 'virsh event'.
      
      * tools/virsh.pod (net-event): Document new command.
      * tools/virsh-network.c (vshNetworkEventToString, vshNetEventData)
      (vshEventLifecyclePrint, cmdNetworkEvent): New struct and
      functions.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      de87691f
    • E
      virsh: add event command, for lifecycle events · 99fa96c3
      Eric Blake 提交于
      Add 'virsh event --list' and 'virsh event [dom] --event=name
      [--loop] [--timeout]'.  Borrows somewhat from event-test.c,
      but defaults to a one-shot notification, and takes advantage
      of the event loop integration to allow Ctrl-C to interrupt the
      wait for an event.  For now, this just does lifecycle events.
      
      * tools/virsh.pod (event): Document new command.
      * tools/virsh-domain.c (vshDomainEventToString)
      (vshDomainEventDetailToString, vshDomEventData)
      (vshEventLifecyclePrint, cmdEvent): New struct and functions.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      99fa96c3
    • E
      virsh: common code for waiting for an event · 4c29530d
      Eric Blake 提交于
      I plan to add 'virsh event' to virsh-domain.c and 'virsh
      net-event' to virsh-network.c; but as they will share quite
      a bit of common boilerplate, it's better to set that up now
      in virsh.c.
      
      * tools/virsh.h (_vshControl): Add fields.
      (vshEventStart, vshEventWait, vshEventDone, vshEventCleanup): New
      prototypes.
      * tools/virsh.c (vshEventFd, vshEventOldAction, vshEventInt)
      (vshEventTimeout): New helper variables and functions.
      (vshEventStart, vshEventWait, vshEventDone, vshEventCleanup):
      Implement new functions.
      (vshInit, vshDeinit, main): Manage event timeout.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4c29530d
    • E
      virsh: common code for parsing --seconds · 5093b047
      Eric Blake 提交于
      Several virsh commands ask for a --timeout parameter in
      seconds, then use it to control interfaces that operate on
      millisecond limits; I also plan on adding a 'virsh event'
      command that also does this.  Factor this into a common
      function.
      
      * tools/virsh.h (vshCommandOptTimeoutToMs): New prototype.
      * tools/virsh.c (vshCommandOptTimeoutToMs): New function.
      * tools/virsh-domain.c (cmdBlockCommit, cmdBlockCopy)
      (cmdBlockPull, cmdMigrate): Use it.
      (vshWatchJob): Adjust timeout scale.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5093b047
    • J
      libxl: queue shutdown event on domain shutdown · 84a6209d
      Jim Fehlig 提交于
      Emit libvirt shutdown event when receiving LIBXL_SHUTDOWN_REASON_POWEROFF
      event from libxl.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      84a6209d
    • J
      bandwidth: Adjust documentation · 7eb37a0d
      John Ferlan 提交于
      Recent autotest/virt-test testing on f20 discovered an anomaly in how
      the bandwidth options are documented and used. This was discovered due
      to a bug fix in the /sbin/tc utility found in iproute-3.11.0.1 (on f20)
      in which overflow was actually caught and returned as an error. The fix
      was first introduced in iproute-3.10 (search on iproute2 commit 'a303853e').
      
      The autotest/virt-test test for virsh domiftune was attempting to send
      the largest unsigned integer value (4294967295) for maximum value
      testing. The libvirt xml implementation was designed to manage values
      in kilobytes thus when this value was passed to /sbin/tc, it (now)
      properly rejected the 4294967295kbps value.
      
      Investigation of the problem discovered that formatdomain.html.in and
      formatnetwork.html.in described the elements and property types slightly
      differently, although they use the same code - virNetDevBandwidthParseRate()
      (shared by portgroups, domains, and networks xml parsers). Rather than
      have the descriptions in two places, this patch will combine and reword
      the description under formatnetwork.html.in and have formatdomain.html.in
      link to that description.
      
      This documentation faux pas was continued into the virsh man page where
      the bandwidth description for both 'attach-interface' and 'domiftune'
      did not indicate the format of each value, thus leading to the test using
      largest unsigned integer value assuming "bps" rather than "kbps", which
      ultimately was wrong.
      7eb37a0d
    • J
      libxl: always use libxlVmCleanupJob in shutdown thread · d716d942
      Jim Fehlig 提交于
      Commit e4a0e900 missed calling libxlVmCleanupJob in the shutdown
      handler when processing a reboot event.
      Signed-off-by: NJim Fehlig <jfehlig@suse.com>
      d716d942
    • E
      qemu: adjust maxmem/maxvcpu computation · 60f7303c
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1038363
      
      If a domain has a different maximum for persistent and live maxmem
      or max vcpus, then it is possible to hit cases where libvirt
      refuses to adjust the current values or gets halfway through
      the adjustment before failing.  Better is to determine up front
      if the change is possible for all requested flags.
      
      Based on an idea by Geoff Franks.
      
      * src/qemu/qemu_driver.c (qemuDomainSetMemoryFlags): Compute
      correct maximum if both live and config are being set.
      (qemuDomainSetVcpusFlags): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      60f7303c