1. 23 3月, 2016 3 次提交
    • A
      hostdev: Streamline device ownership tracking · 81128609
      Andrea Bolognani 提交于
      After this patch, ownership of virPCIDevice instances is very easy
      to keep track of: for each host PCI device, the only instance that
      actually matters is the one inside one of the bookkeeping list.
      
      Whenever some operation needs to be performed on a PCI device, the
      actual device is looked up first; when this is not the case, a
      comment explains the reason.
      81128609
    • A
      hostdev: Stop early if unmanaged devices have not been detached · 6da6bf2f
      Andrea Bolognani 提交于
      Unmanaged devices, as the name suggests, are not detached
      automatically from the host by libvirt before being attached to a
      guest: it's the user's responsability to detach them manually
      beforehand. If that preliminary step has not been performed, the
      attach operation can't complete successfully.
      
      Instead of relying on the lower layers to error out with cryptic
      messages such as
      
        error: Failed to attach device from /tmp/hostdev.xml
        error: Path '/dev/vfio/12' is not accessible: No such file or directory
      
      prevent the situation altogether and provide the user with a more
      useful error message.
      6da6bf2f
    • A
      hostdev: Detect untracked inactive devices · df490e7c
      Andrea Bolognani 提交于
      Unmanaged devices are attached to guests in two steps: first,
      the device is detached from the host and marked as inactive;
      subsequently, it is marked as active and attached to the guest.
      
      If the daemon is restarted between these two operations, we lose
      track of the inactive device.
      
      Steps 5 and 6 of virHostdevPreparePCIDevices() already subtly
      take care of this situation, but some planned changes will make
      it so that's no longer the case. Plus, explicit is always better
      than implicit.
      df490e7c
  2. 21 3月, 2016 1 次提交
    • M
      util: Add virSocketAddrSetIPv[46]AddrNetOrder and use it · 573c41a2
      Martin Kletzander 提交于
      This allows setting the address in host and/or network order and makes
      the naming consistent.  Now you don't need to call [hn]to[nh]l()
      functions as that is taken care of by these functions.  Also, now
      the *NetOrder take the address in network order, the other functions in
      host order so the naming and usage is consistent.  Some places were
      having the address in network order and calling ntohl() just so the
      original function can call htonl() again.  This makes it nicer to read.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      573c41a2
  3. 19 3月, 2016 5 次提交
  4. 18 3月, 2016 1 次提交
    • M
      Drop paths.h include · 865764de
      Michal Privoznik 提交于
      We include the file in plenty of places. This is mostly due to
      historical reasons. The only place that needs something from the
      header file is storage_backend_fs which opens _PATH_MOUNTED. But
      it gets the file included indirectly via mntent.h. At no other
      place in our code we need _PATH_.*. Drop the include and
      configure check then.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      865764de
  5. 17 3月, 2016 1 次提交
  6. 16 3月, 2016 2 次提交
    • E
      virlog: Refactor virLogParseOutputs · 0b231195
      Erik Skultety 提交于
      The problem with the original virLogParseOutputs method was that the way it
      parsed the input, walking the string char by char and using absolute jumps
      depending on the virLogDestination type, was rather complicated to read.
      This patch utilizes virStringSplit method twice, first time to filter out any
      spaces and split the input to individual log outputs and then for each
      individual output to tokenize it by to the parts according to our
      PRIORITY:DESTINATION?(:DATA) format. Also, to STREQLEN for matching destination
      was replaced with virDestinationTypeFromString call.
      0b231195
    • E
      virlog: Introduce Type{To,From}String for virLogDestination · 034337fb
      Erik Skultety 提交于
      In order to refactor the ugly virLogParseOutputs method, this is a neat way of
      finding out whether the destination type (in the form of a string) user
      provided is a valid one. As a bonus, if it turns out it is valid, we get the
      actual enum which will later be passed to any of virLogAddOutput methods right
      away.
      034337fb
  7. 15 3月, 2016 3 次提交
    • A
      hostdev: Add more comments · 5fc68bd4
      Andrea Bolognani 提交于
      These comments explain the difference between a virPCIDevice
      instance used for lookups and an actual device instance; some
      information is also provided for specific uses.
      5fc68bd4
    • A
      hostdev: Use consistent variable names · 800dd16d
      Andrea Bolognani 提交于
      This is not just a cosmetic change: the name of the variable now
      gives a hint about what it is supposed to be used for.
      800dd16d
    • A
      hostdev: Remove virHostdevGetActivePCIHostDeviceList() · 4cdbff3d
      Andrea Bolognani 提交于
      virHostdevGetPCIHostDeviceList() is similar but does not filter out
      devices that are not in the active list; that said, we are looking
      up the device in the active list just a few lines after anyway, so
      we might as well just keep a single function around.
      
      This also helps stress the fact the objects contained in pcidevs are
      only for looking up the actual devices, which is something later
      commits will make even more explicit.
      4cdbff3d
  8. 14 3月, 2016 6 次提交
  9. 11 3月, 2016 1 次提交
  10. 10 3月, 2016 2 次提交
  11. 08 3月, 2016 4 次提交
    • A
      hostdev: Remove explicit NULL checks · 12a16314
      Andrea Bolognani 提交于
      NULL checks are performed implicitly in the rest of the module,
      including other allocations in the very same function.
      12a16314
    • A
      hostdev: Fix indentation · a54de18a
      Andrea Bolognani 提交于
      a54de18a
    • A
      hostdev: Remove inaccurate comment · a67b14a9
      Andrea Bolognani 提交于
      The comment claimed that virPCIDeviceReattach() does not reattach
      a device to the host driver; except it actually does, so the
      comment is just confusing and we're better off removing it.
      a67b14a9
    • A
      hostdev: Make comments easier to change later · be70acb7
      Andrea Bolognani 提交于
      Replace the term "loop" with the more generic "step". This allows us
      to be more flexible and eg. have a step that consists in a single
      function call.
      
      Don't include the number of steps in the first comment of the
      function, so that we can add or remove steps without having to worry
      about keeping that comment in sync.
      
      For the same reason, remove the summary contained in that comment.
      
      Clean up some weird vertical spacing while we're at it.
      be70acb7
  12. 03 3月, 2016 2 次提交
    • M
      Drop inline keyword from some functions. · be8b536a
      Michal Privoznik 提交于
      While trying to build with -Os I've encountered some build
      failures.
      
      util/vircommand.c: In function 'virCommandAddEnvFormat':
      util/vircommand.c:1257:1: error: inlining failed in call to 'virCommandAddEnv': call is unlikely and code size would grow [-Werror=inline]
       virCommandAddEnv(virCommandPtr cmd, char *env)
       ^
      util/vircommand.c:1308:5: error: called from here [-Werror=inline]
           virCommandAddEnv(cmd, env);
           ^
      This function is big enough for the compiler to be not inlined.
      This is the error message I'm seeing:
      
      Then virDomainNumatuneNodeSpecified is exported and called from
      other places. It shouldn't be inlined then.
      
      In file included from network/bridge_driver_platform.h:30:0,
                       from network/bridge_driver_platform.c:26:
      network/bridge_driver_linux.c: In function 'networkRemoveRoutingFirewallRules':
      ./conf/network_conf.h:350:1: error: inlining failed in call to 'virNetworkDefForwardIf.constprop': call is unlikely and code size would grow [-Werror=inline]
       virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
       ^
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      be8b536a
    • J
      util: Cleanup error path for virPolkitAgentCreate · 0b36b0e9
      John Ferlan 提交于
      More fallout from changing to using virPolkitAgent and handling error
      paths.  Needed to clear the 'cmd' once stored and of course add the
      virCommandFree(cmd) in the error: label.
      0b36b0e9
  13. 02 3月, 2016 1 次提交
    • J
      util: Fix missing initializer for agent · 95aa1017
      John Ferlan 提交于
      In virPolkitAgentCreate neglected to initialize agent to NULL. If
      there was an error in the pipe, then we jump to error and would have
      an issue. Found by coverity.
      95aa1017
  14. 01 3月, 2016 5 次提交
    • J
      util: Fix build without polkit · 254b0289
      Jiri Denemark 提交于
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      254b0289
    • H
      qemu_cgroup: use virCgroupAddTask instead of virCgroupMoveTask · ff16bde1
      Henning Schild 提交于
      qemuProcessSetupEmulator runs at a point in time where there is only
      the qemu main thread. Use virCgroupAddTask to put just that one task
      into the emulator cgroup. That patch makes virCgroupMoveTask and
      virCgroupAddTaskStrController obsolete.
      Signed-off-by: NHenning Schild <henning.schild@siemens.com>
      ff16bde1
    • J
      util: Introduce API's for Polkit text authentication · 6fb96a7f
      John Ferlan 提交于
      Introduce virPolkitAgentCreate and virPolkitAgentDestroy
      
      virPolkitAgentCreate will run the polkit pkttyagent image as an asynchronous
      command in order to handle the local agent authentication via stdin/stdout.
      The code makes use of the pkttyagent --notify-fd mechanism to let it know
      when the agent is successfully registered.
      
      virPolkitAgentDestroy will close the command effectively reaping our
      child process
      6fb96a7f
    • J
      polkit: Adjust message when authentication agent isn't found · 1d35f6ff
      John Ferlan 提交于
      When there isn't a ssh -X type session running and a user has not
      been added to the libvirt group, attempts to run 'virsh -c qemu:///system'
      commands from an otherwise unprivileged user will fail with rather
      generic or opaque error message:
      
          "error: authentication failed: no agent is available to authenticate"
      
      This patch will adjust the error code and message to help reflect the
      situation that the problem is the requested mechanism is UNAVAILABLE and
      a slightly more descriptive error. The result on a failure then becomes:
      
          "error: authentication unavailable: no polkit agent available to
                  authenticate action 'org.libvirt.unix.manage'"
      
      A bit more history on this - at one time a failure generated the
      following type message when running the 'pkcheck' as a subprocess:
      
      "error: authentication failed: polkit\56retains_authorization_after_challenge=1
      Authorization requires authentication but no agent is available."
      
      but, a patch was generated to adjust the error message to help provide
      more details about what failed. This was pushed as commit id '96a108c9'.
      That patch prepended a "polkit: " to the output. It really didn't solve
      the problem, but gave a hint.
      
      After some time it was deemed using DBus API calls directly was a
      better way to go (since pkcheck calls them anyway). So, commit id
      '1b854c76' (more or less) copied the code from remoteDispatchAuthPolkit
      and adjusted it. Then commit id 'c7542573' adjusted the remote.c
      code to call the new API (virPolkitCheckAuth). Finally, commit id
      '308c0c5a' altered the code to call DBus APIs directly. In doing
      so, it reverted the failing error message to the generic message
      that would have been received from DBus anyway.
      1d35f6ff
    • H
      vircgroup: one central point for adding tasks to cgroups · 85d74806
      Henning Schild 提交于
      Use virCgroupAddTaskController in virCgroupAddTask so we have one
      single point where we add tasks to cgroups.
      Signed-off-by: NHenning Schild <henning.schild@siemens.com>
      85d74806
  15. 26 2月, 2016 2 次提交
    • A
      hostdev: Remove temporary variable when checking for VF · b2ce5b02
      Andrea Bolognani 提交于
      The virHostdevIsVirtualFunction() was called exactly twice, and in
      both cases the return value was saved to a temporary variable before
      being checked. This would be okay if it improved readability, but in
      this case is pretty pointless.
      
      Get rid of the temporary variable and check the return value
      directly; while at it, change the check from '<= 0' to '!= 1' to
      align it with the way other similar *IsVirtualFunction() functions
      are used thorough the code.
      b2ce5b02
    • A
      netdev: Use virNetDevIsVirtualFunction() properly · dec3a4a1
      Andrea Bolognani 提交于
      virNetDevIsVirtualFunction() returns 1 if the interface is a
      virtual function, 0 if it isn't and -1 on error. This means that,
      despite the name suggesting otherwise, using it as a predicate is
      not correct.
      
      Fix two callers that were doing so adding an explicit check on
      the return value.
      dec3a4a1
  16. 25 2月, 2016 1 次提交