1. 11 12月, 2012 7 次提交
    • L
      conf: put data for network <forward> element into its own struct · 47c94b65
      Laine Stump 提交于
      The attributes of a <network> element's <forward> element were
      previously stored directly in the virNetworkDef object, but
      virNetworkUpdateForward() needs to operate on a <forward> in
      isolation, so this patchs pulls out all those attributes into a
      separate virNetworkForwardDef struct (and shortens their names
      appropriately). This new object is contained in the virNetworkDef, not
      pointed to by it, so there is no extra memory management.
      
      This patch makes no functional changes, it only changes, e.g.,
      "nForwardIfs" to "forward.nifs".
      47c94b65
    • L
      conf: make virNetworkIpDefClear consistent with other functions · 31d21197
      Laine Stump 提交于
      The other clear functions in network_conf.c that clear out arrays of
      sub-objects do so by using the n[itemname]s value as a counter going
      down to 0. Make this one consistent. There's no functional value, just
      makes the style more consistent with the rest of the file.
      31d21197
    • L
      conf: rename some labels and functions in network_conf · dc9d8d68
      Laine Stump 提交于
      This makes some function names and arg lists for consistent with other
      parse functions in network_conf.c. While modifying
      virNetworkIPParseXML(), also change its "error" label to "cleanup",
      since the code at that label is executed on success as well as
      failure.
      dc9d8d68
    • L
      network: backend functions for updating network dns host/srv/txt · fc19a005
      Laine Stump 提交于
      These three functions are very similar - none allow a MODIFY
      operation; you can only add or delete.
      
      The biggest difference between them (other than the data itself) is in
      the criteria for determining a match, and whether or not multiple
      matches are possible:
      
      1) for HOST records, it's considered a match if the IP address or any
      of the hostnames of an existing record matches.
      
      2) for SRV records, it's a match if all of
      domain+service+protocol+target *which have been specified* are
      matched.
      
      3) for TXT records, there is only a single field to match - name
      (value can be the same for multiple records, and isn't considered a
      search term), so by definition there can be no ambiguous matches.
      
      In all three cases, if any matches are found, ADD will fail; if
      multiple matches are found, it means the search term was ambiguous,
      and a DELETE will fail.
      
      The upper level code in bridge_driver.c is already implemented for
      these functions - appropriate conf files will be re-written, and
      dnsmasq will be SIGHUPed or restarted as appropriate.
      fc19a005
    • L
      conf: clear and parse functions for dns host/srv/txt records · ab297bec
      Laine Stump 提交于
      Since there is only a single virNetworkDNSDef for any virNetworkDef,
      and it's trivial to determine whether or not it contains any real
      data, it's much simpler (and fits more uniformly with the parse
      function calling sequence of the parsers for many other objects that
      are subordinates of virNetworkDef) if virNetworkDef *contains* an
      virNetworkDNSDef rather than pointing to one.
      
      Since it is now just a part of another object rather than its own
      object, it no longer makes sense to have a *Free() function, so that
      is changed to a *Clear() function.
      
      More importantly though, ParseXML and Clear functions are needed for
      the individual items contained in a virNetworkDNSDef (srv, txt, and
      host records), but none of them have a *Clear(), and only two of the
      three had *ParseXML() functions (both of which used a non-uniform
      arglist). Those problems are cleared up by this patch - it splits the
      higher-level Clear function into separate functions for each of the
      three, creates a parse for txt records, and cleans up the srv and host
      parsers, so we now have all the utility functions necessary to
      implement virNetworkDefUpdateDNS(Host|Srv|Txt).
      ab297bec
    • L
      conf: rename network dns host/srv/txt arrays · 8b7d1874
      Laine Stump 提交于
      This shortens the name of the structs for srv and txt, and their
      instances in virNetworkDNSDef, to be more compact and uniform with the
      naming of the dns host array. It also changes the type of ntxts, etc
      from unsigned int to size_t, so that they can be used directly as args
      to VIR_*_ELEMENT.
      8b7d1874
    • L
      conf: use VIR_(INSERT|DELETE)_ELEMENT in virNetworkUpdate backend · 2dc5839a
      Laine Stump 提交于
      The already-written backend functions for virNetworkUpdate that add
      and delete items into lists within the a network were already debugged
      to work properly, but future such functions will use
      VIR_(INSERT|DELETE)_ELEMENT instead, so these are changed for
      uniformity.
      2dc5839a
  2. 06 12月, 2012 2 次提交
    • L
      network: prevent a few invalid configuration combinations · fd54f1de
      Laine Stump 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=767057
      
      It was possible to define a network with <forward mode='bridge'> that
      had both a bridge device and a forward device defined. These two are
      mutually exclusive by definition (if you are using a bridge device,
      then this is a host bridge, and if you have a forward dev defined,
      this is using macvtap). It was also possible to put <ip>, <dns>, and
      <domain> elements in this definition, although those aren't supported
      by the current driver (although it's conceivable that some other
      driver might support that).
      
      The items that are invalid by definition, are now checked in the XML
      parser (since they will definitely *always* be wrong), and the others
      are checked in networkValidate() in the network driver (since, as
      mentioned, it's possible that some other network driver, or even this
      one, could some day support setting those).
      fd54f1de
    • G
      network: allow guest to guest IPv6 without gateway definition · 705e67d4
      Gene Czarcinski 提交于
      This patch adds the capability for virtual guests to do IPv6
      communication via a virtual network interface with no IPv6 (gateway)
      addresses specified.  This capability has always been enabled by
      default for IPv4, but disabled for IPv6 for security concerns, and
      because it requires the ip6tables command to be operational (which
      isn't the case on a system with the ipv6 module completely disabled).
      
      This patch adds a new attribute "ipv6" at the toplevel of a <network>
      object.  If ipv6='yes', the extra ip6tables rules required to permite
      inter-guest communications are added when the network is started. If
      it is 'no', or not present, those rules will not be added; thus the
      default behavior doesn't change, so there should be no compatibility
      issues with any existing installations.
      
      Note that virtual guests cannot communication with the virtualization
      host via this interface, because the following kernel tunable has
      been set:
      
         net.ipv6.conf.<bridge_interface_name>.disable_ipv6 = 1
      
      This assures that the bridge interface will not have an IPv6
      link-local (fe80::) address.
      
      To control this behavior so that it is not enabled by default, the parameter
      ipv6='yes' on the <network> statement has been added.
      
      Documentation related to this patch has been updated.
      The network schema has also been updated.
      705e67d4
  3. 29 11月, 2012 1 次提交
    • L
      network: fix crash when portgroup has no name · 012d69df
      Laine Stump 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=879473
      
      The name attribute is required for portgroup elements (yes, the RNG
      specifies that), and there is code in libvirt that assumes it is
      non-null.  Unfortunately, the portgroup parsing function wasn't
      checking for lack of portgroup. One adverse result of this was that
      attempts to update a network by adding a portgroup with no name would
      cause libvirtd to segfault. For example:
      
         virsh net-update default add portgroup "<portgroup default='yes'/>"
      
      This patch causes virNetworkPortGroupParseXML to fail if no name is
      specified, thus avoiding any later problems.
      012d69df
  4. 02 11月, 2012 4 次提交
  5. 29 10月, 2012 1 次提交
    • J
      xml: print uuids in the warning · 0b121614
      Ján Tomko 提交于
      In the XML warning, we print a virsh command line that can be used to
      edit that XML. This patch prints UUIDs if the entity name contains
      special characters (like shell metacharacters, or "--" that would break
      parsing of the XML comment). If the entity doesn't have a UUID, just
      print the virsh command that can be used to edit it.
      0b121614
  6. 21 10月, 2012 1 次提交
    • L
      network: don't allow multiple default portgroups · 6f8a8b30
      Laine Stump 提交于
      This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=868483
      
      virNetworkUpdate, virNetworkDefine, and virNetworkCreate all three
      allow network definitions to contain multiple <portgroup> elements
      with default='yes'. Only a single default portgroup should be allowed
      for each network.
      
      This patch updates networkValidate() (called by both
      virNetworkCreate() and virNetworkDefine()) and
      virNetworkDefUpdatePortGroup (called by virNetworkUpdate() to not
      allow multiple default portgroups.
      6f8a8b30
  7. 20 10月, 2012 1 次提交
    • L
      network: free/null newDef if network fails to start · 78fab277
      Laine Stump 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=866364
      
      pointed out a crash due to virNetworkObjAssignDef free'ing
      network->newDef without NULLing it afterward. A fix for this is in
      upstream commit b7e92024. While the
      NULLing of newDef was a legitimate fix, newDef should have already
      been empty (NULL) anyway (as indicated in the comment that was deleted
      by that commit).
      
      The reason that newDef had a non-NULL value (i.e. the root cause) was
      that networkStartNetwork() had failed after populating
      network->newDef, but then neglected to free/NULL newDef in the
      cleanup.
      
      (A bit of background here: network->newDef should contain the
      persistent config of a network when a network is active (and of course
      only when it is persisten), and NULL at all other times. There is also
      a network->def which should contain the persistent definition of the
      network when it is inactive, and the current live state at all other
      times. The idea is that you can make changes to network->newDef which
      will take effect the next time the network is restarted, but won't
      mess with the current state of the network (virDomainObj has a similar
      pair of virDomainDefs that behave in the same fashion). Personally I
      think there should be a network->live and network->config, and the
      location of the persistent config should *always* be in
      network->config, but that's for a later cleanup).
      
      Since I love things to be symmetric, I created a new function called
      virNetworkObjUnsetDefTransient(), which reverses the effects of
      virNetworkObjSetDefTransient(). I don't really like the name of the
      new function, but then I also didn't really like the name of the old
      one either (it's just named that way to match a similar function in
      the domain conf code).
      78fab277
  8. 18 10月, 2012 1 次提交
    • M
      network: Set to NULL after virNetworkDefFree() · b7e92024
      Michal Privoznik 提交于
      which frees all allocated memory but doesn't set the passed pointer to
      NULL.  Therefore, we must do it ourselves. This is causing actual
      libvirtd crash: Basically, when doing 'virsh net-edit' the newDef should
      be dropped.  And the memory is freed, indeed. However, the pointer is
      not set to NULL but kept instead. And the next duo of calls 'virsh
      net-start' and 'virsh net-destroy' starts the disaster. The latter one
      does the same as 'virsh destroy'; it sees that newDef is nonNULL so it
      replaces def with newDef (which has been freed already as said a few
      lines above). Therefore any subsequent call accessing def will hit the ground.
      b7e92024
  9. 27 9月, 2012 1 次提交
    • L
      network: backend for virNetworkUpdate of interface list · 024879e5
      Laine Stump 提交于
      <interface> elements are location inside the <forward> element of a
      network. There is only one <forward> element in any network, but it
      might have many <interface> elements. This element only contains a
      single attribute, "dev", which is the name of a network device
      (e.g. "eth0").
      
      Since there is only a single attribute, the modify operation isn't
      supported for this "section", only add-first, add-last, and
      delete. Also, note that it's not permitted to delete an interface from
      the list while any guest is using it. We may later decide this is safe
      (because removing it from the list really only excludes it from
      consideration in future guest allocations of interfaces, but doesn't
      affect any guests currently connected), but for now this limitation
      seems prudent (of course when changing the persistent config, this
      limitation doesn't apply, because the persistent config doesn't
      support the concept of "in used").
      
      Another limitation - it is also possible for the interfraces in this
      list to be described by PCI address rather than netdev name. However,
      I noticed while writing this function that we currently don't support
      defining interfaces that way in config - the only method of getting
      interfaces specified as <adress type='pci' ..../> instead of
      <interface dev='xx'/> is to provide a <pf dev='yy'/> element under
      forward, and let the entries in the interface list be automatically
      populated with the virtual functions (VF) of the physical function
      device given in <pg>.
      
      As with the other virNetworkUpdate section backends, support for this
      section is completely contained within a single static function, no
      other changes were required, and only functions already called from
      elsewhere within the same file are used in the new content for this
      existing function (i.e., adding this code should not cause a new build
      problem on any platform).
      024879e5
  10. 22 9月, 2012 2 次提交
    • L
      network: log error for unknown virNetworkUpdate command codes · 5cdcb75d
      Laine Stump 提交于
      Every level of the code for virNetworkUpdate was assuming that some
      other level was checking for validity of the "command" arg, but none
      actually were. The result was that an invalid command code would do
      nothing, but also report success.
      
      Since the command code isn't used until the very lowest level backend
      functions, that's where I put the check. I made a separate one-line
      function to log the error. The compiler would have combined the
      identical strings used by multiple calls if I'd just called
      virReportError directly in each location, but sending them all to the
      same string in the source guards against inadvertant divergence (which
      would lead to extra work for translators.)
      5cdcb75d
    • L
      network: make virNetworkObjUpdate error detection/recovery better · f59e25e0
      Laine Stump 提交于
      1) virNetworkObjUpdate should be an all or none operation, but in the
      case that we want to update both the live state and persistent config
      versions of the network, it was committing the update to the live
      state before starting to update the persistent config. If update of
      the persistent config failed, we would leave with things in an
      inconsistent state - the live state would be updated (even though an
      error was returned), but persistent config unchanged.
      
      This patch changed virNetworkObjUpdate to use a separate pointer for
      each copy of the virNetworkDef, and not commit either of them in the
      virNetworkObj until both live and config parts of the update have
      successfully completed.
      
      2) The parsers for various pieces of the virNetworkDef have all sorts
      of subtle limitations on them that may not be known by the
      Update[section] function, making it possible for one of these
      functions to make a modification directly to the object that may not
      pass the scrutiny of a subsequent parse. But normally another parse
      wouldn't be done on the data until the *next* time the object was
      updated (which could leave the network definition in an unusable
      state).
      
      Rather than fighting the losing battle of trying to duplicate all the
      checks from the parsers into the update functions as well, the more
      foolproof solution to this is to simply do an extra
      virNetworkDefCopy() operation on the updated networkdef -
      virNetworkDefCopy() does a virNetworkFormat() followed by a
      virNetworkParseString(), so it will do all the checks we need. If this
      fails, then we don't commit the changed def.
      f59e25e0
  11. 21 9月, 2012 3 次提交
    • L
      network: backend for virNetworkUpdate of portgroups · 8b6f831c
      Laine Stump 提交于
      portgroup elements are located in the toplevel of <network>
      objects. There can be multiple <portgroup> elements, and they each
      have a unique name attribute.
      
      Add, delete, and modify are all supported for portgroup. When deleting
      a portgroup, only the name must be specified in the provided xml - all
      other attributes and subelements are ignored for the purposes of
      matching and existing portgroup.
      
      The bridge driver and virsh already know about the portgroup element,
      so providing this backend should cause the entire stack to work. Note
      that in the case of portgroup, there is no external daemon based on
      the portgroup config, so nothing must be restarted.
      
      It is important to note that guests make a copy of the appropriate
      network's portgroup data when they are started, so although an updated
      portgroup's configuration will have an affect on new guests started
      after the cahange, existing guests won't magically have their
      bandwidth changed, for example. If something like that is desired, it
      will take a lot of redesign work in the way network devices are setup
      (there is currently no link from the network back to the individual
      interfaces using it, much less from a portgroup within a network back
      to the individual interfaces).
      8b6f831c
    • L
      network: backend for virNetworkUpdate of dhcp range · 1100f610
      Laine Stump 提交于
      The dhcp range element is contained in the <dhcp> element of one of a
      network's <ip> elements. There can be multiple <range>
      elements. Because there are only two attributes (start and end), and
      those are exactly what you would use to identify a particular range,
      it doesn't really make sense to modify an existing element, so
      VIR_NETWORK_UPDATE_COMMAND_MODIFY isn't supported for this section,
      only ADD_FIRST, ADD_LAST, and DELETE.
      
      Since virsh already has support for understanding all the defined
      sections, this new backend is automatically supported by virsh. You
      would use it like this:
      
        virsh net-update mynet add ip-dhcp-range \
              "<range start='1.2.3.4' end='1.2.3.20'/>" --live --config
      
      The bridge driver also already supports all sections, so it's doing
      the correct thing in this case as well - since the dhcp range is
      placed on the dnsmasq commandline, the bridge driver recreates the
      dnsmasq commandline, and re-runs dnsmasq whenever a range is
      added/deleted (and AFFECT_LIVE is specified in the flags).
      1100f610
    • E
      maint: fix up copyright notice inconsistencies · 4ecb723b
      Eric Blake 提交于
      https://www.gnu.org/licenses/gpl-howto.html recommends that
      the 'If not, see <url>.' phrase be a separate sentence.
      
      * tests/securityselinuxhelper.c: Remove doubled line.
      * tests/securityselinuxtest.c: Likewise.
      * globally: s/;  If/.  If/
      4ecb723b
  12. 20 9月, 2012 1 次提交
    • L
      network: fix element size / length in memmove · db8760ff
      Laine Stump 提交于
      The memmove to move elements in the dhcp hosts array when inserting
      and deleting items was mistakenly basing the length of the copy on the
      size of a virNetworkDHCPHostDefPtr rather than virNetworkDHCPHostDef,
      with the expected disastrous results.
      
      The memmove to delete an entry commits two errors - along with the
      size of each element being wrong, it also omits some required
      parentheses.
      db8760ff
  13. 18 9月, 2012 5 次提交
    • L
      network: implement backend of virNetworkUpdate(IP_DHCP_HOST) · e3b6b2be
      Laine Stump 提交于
      This patch fills in the first implementation for one of the
      virNetworkUpdate sections. With this code, you can now add/delete/edit
      <host> entries in a network's <ip> address <dhcp> element (by
      specifying a section of VIR_NETWORK_SECTION_IP_DHCP_HOST).
      
      If you pass in a parentIndex of -1, the code will automatically find
      the one ip element that has a <dhcp> section and make the updates
      there. Otherwise, you can specify an index >= 0, and libvirt will look
      for that particular instance of <ip> in the network, and modify its
      <dhcp> element. (This currently isn't very useful, because libvirt
      only supports having dhcp information on a single IP address, but that
      could change in the future).
      
      When adding a new host entry
      (VIR_NETWORK_UPDATE_COMMAND_ADD_(FIRST|LAST)), the existing entries
      will be compared to the new entry, and if any non-empty attribute
      matches, the add will fail. When updating an existing entry
      (VIR_NETWORK_UPDATE_COMMAND_MODIFY), the mac address or name will be
      used to find the existing entry, and other fields will only be updated
      (note there is some potential for ambiguity here if you specify the
      mac address from one entry and the name from another).  When deleting
      an existing entry (VIR_NETWORK_UPDATE_COMMAND_DELETE), all non-empty
      attributes in the supplied xml arg will be compared - all of them must
      match before libvirt will delete the host.
      
      The xml should be a fully formed <host> element as it would appear in
      a network definition, e.g. "<host mac=00:11:22:33:44:55 ip=10.1.23.22
      name='testbox'/>" (when adding/updating, ip and one of mac|name is
      required; when deleting, you can specify any one, two, or all
      attributes, but they all must match the target element).
      
      As with the update of any other section, you can choose to affect the
      live config (with flag VIR_NETWORK_UPDATE_AFFECT_LIVE), the persistent
      config (VIR_NETWORK_UPDATE_AFFECT_CONFIG), or both. If you've chosen
      to affect the live config, those changes will take effect immediately,
      with no need to destroy/restart the network.
      
      An example of adding a host entry:
      
         virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_ADD_LAST,
                           VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
                          "<host mac='00:11:22:33:44:55' ip='192.168.122.5'/>",
                          VIR_NETWORK_UPDATE_AFFECT_LIVE
                          | VIR_NETWORK_UPDATE_AFFECT_CONFIG);
      
      To delete that same entry:
      
         virNetworkUpdate(net, VIR_NETWORK_UPDATE_COMMAND_DELETE,
                          VIR_NETWORK_SECTION_IP_DHCP_HOST, -1,
                          "<host mac='00:11:22:33:44:55'/>",
                          VIR_NETWORK_UPDATE_AFFECT_LIVE
                          | VIR_NETWORK_UPDATE_AFFECT_CONFIG);
      
      (you could also delete it by replacing "mac='00:11:22:33:44:55'" with
      "ip='192.168.122.5'".)
      e3b6b2be
    • L
      conf: implement NetworkObj backend of virNetworkUpdate API · d22f4bad
      Laine Stump 提交于
      virNetworkObjUpdate takes care of all virNetworkUpdate-related changes
      to the data stored in the in-memory virNetworkObj list. It should be
      called by network drivers that use this in-memory list.
      
      virNetworkObjUpdate *does not* take care of updating any disk-based
      copies of the config, nor does it perform any other operations
      necessary to have the new config data take effect (e.g. it won't
      re-write dnsmasq host files, nor will it send a SIGHUP to dnsmasq) -
      those things should all be taken care of in the network driver
      function that calls virNetworkObjUpdate (assuming that it returns
      success).
      d22f4bad
    • L
      network: utility functions for updating network config · f36309d6
      Laine Stump 提交于
      These new functions are highly inspired by those in domain_conf.c (but
      not identical), and are intended to make it simpler to update the
      various combinations of live/persistent network configs.
      
      The network driver wasn't previously as careful about the separation
      between the live "status" in network->def and the persistent "config"
      in network->newDef (or sometimes in network->def). This series
      attempts to remedy some of that, but probably doesn't go all the way
      (enough to get these functions working and enable continued work on
      virNetworkUpdate though).
      
      bridge_driver.c and test_driver.c were updated in a few places to take
      advantage of the new functions and/or account for changes in argument
      lists.
      f36309d6
    • L
      conf: avoid freeing network object with undestroyed mutex · 16d9a3df
      Laine Stump 提交于
      virNetworkAssignDef was allocating a new network object, initing and
      grabbing its lock, then potentially freeing it without unlocking or
      destroying the lock. In practice 1) this will probably never happen,
      and 2) even if it did, the lock implementation used on most (all?)
      platforms doesn't actually hold any resources for an initialized or
      held lock, but it still bothered me, so I moved the realloc that could
      lead to this bad situation earlier in the function, and now the mutex
      isn't inited or locked until we are assured of complete success.
      16d9a3df
    • L
      conf: separate functions to parse DHCPHostDef and DHCPRangeDef · 764bd853
      Laine Stump 提交于
      These two objects were previously always parsed as a part of an IpDef,
      but we will now need to be able to parse them on their own for
      virNetworkUpdate(). Split the parsing functions out, with no
      functional changes.
      764bd853
  14. 11 9月, 2012 1 次提交
    • O
      list: Add helpers to list network objects · d3c6cabb
      Osier Yang 提交于
      src/conf/network_conf.c: Add virNetworkMatch to filter the networks;
      and virNetworkList to iterate over all the networks with the filter.
      
      src/conf/network_conf.h: Declare virNetworkList and define the macros
      for filters.
      
      src/libvirt_private.syms: Export virNetworkList.
      d3c6cabb
  15. 18 8月, 2012 1 次提交
  16. 16 8月, 2012 1 次提交
    • L
      conf: add <vlan> element to network and domain interface elements · 3f9274a5
      Laine Stump 提交于
      The following config elements now support a <vlan> subelements:
      
      within a domain: <interface>, and the <actual> subelement of <interface>
      within a network: the toplevel, as well as any <portgroup>
      
      Each vlan element must have one or more <tag id='n'/> subelements.  If
      there is more than one tag, it is assumed that vlan trunking is being
      requested. If trunking is required with only a single tag, the
      attribute "trunk='yes'" should be added to the toplevel <vlan>
      element.
      
      Some examples:
      
        <interface type='hostdev'/>
          <vlan>
            <tag id='42'/>
          </vlan>
          <mac address='52:54:00:12:34:56'/>
          ...
        </interface>
      
        <network>
          <name>vlan-net</name>
          <vlan trunk='yes'>
            <tag id='30'/>
          </vlan>
          <virtualport type='openvswitch'/>
        </network>
      
        <interface type='network'/>
          <source network='vlan-net'/>
          ...
        </interface>
      
        <network>
          <name>trunk-vlan</name>
          <vlan>
            <tag id='42'/>
            <tag id='43'/>
          </vlan>
          ...
        </network>
      
        <network>
          <name>multi</name>
          ...
          <portgroup name='production'/>
            <vlan>
              <tag id='42'/>
            </vlan>
          </portgroup>
          <portgroup name='test'/>
            <vlan>
              <tag id='666'/>
            </vlan>
          </portgroup>
        </network>
      
        <interface type='network'/>
          <source network='multi' portgroup='test'/>
          ...
        </interface>
      
      IMPORTANT NOTE: As of this patch there is no backend support for the
      vlan element for *any* network device type. When support is added in
      later patches, it will only be for those select network types that
      support setting up a vlan on the host side, without the guest's
      involvement. (For example, it will be possible to configure a vlan for
      a guest connected to an openvswitch bridge, but it won't be possible
      to do that for one that is connected to a standard Linux host bridge.)
      3f9274a5
  17. 15 8月, 2012 5 次提交
    • L
      network: add connections counter to networks · 300bcdb6
      Laine Stump 提交于
      Just as each physical device used by a network has a connections
      counter, now each network has a connections counter which is
      incremented once for each guest interface that connects using this
      network.
      
      The count is output in the live network XML, like this:
      
         <network connections='20'>
         ...
         </network>
      
      It is read-only, and for informational purposes only - it isn't used
      internally anywhere by libvirt.
      300bcdb6
    • L
      conf: output forward device connections count in network XML · 92a83040
      Laine Stump 提交于
      It may be useful for management applications to know which physical
      network devices are in use by guests. This information is already
      available in the network objects, but wasn't output in the XML. This
      patch outputs it when the INACTIVE flag isn't set (and if it's non-0).
      92a83040
    • L
      conf: rename interface "usageCount" to "connections" · 643feae7
      Laine Stump 提交于
      I want to include this count in the xml output of networks, but
      calling it "connections" in the XML sounds better than "usageCount", and it
      would be better if the name in the XML matched the variable name.
      
      In a few places, usageCount was being initialized to 0, but this is
      unnecessary, because VIR_ALLOC_N zero-fills everything anyway.
      643feae7
    • L
      conf: use a unique data type for PF array in virDomainNetDef · 95ae4e7f
      Laine Stump 提交于
      This array was originally defined using the existing
      virNetworkForwardIfDef, but that struct has a UsageCount field that
      isn't used in the case of PFs. This patch just copies that struct and
      removes UsageCount. It ends up being a struct with a single field, but
      I left it as a struct in case we need to add other fields to it in the
      future.
      95ae4e7f
    • L
      conf: support partially-specified <virtualport> in parser and formatter · 4af3cbaf
      Laine Stump 提交于
      Until now, all attributes in a <virtualport> parameter list that were
      acceptable for a particular type, were also required. There were no
      optional attributes.
      
      One of the aims of supporting <virtualport> in libvirt's virtual
      networks and portgroups is to allow specifying the group-wide
      parameters in the network's virtualport, and merge that with the
      interface's virtualport, which will have the instance-specific info
      (i.e. the interfaceid or instanceid).
      
      Additionally, the guest's interface XML shouldn't need to know what
      type of network connection will be used prior to runtime - it could be
      openvswitch, 802.1Qbh, 802.1Qbg, or none of the above - but should
      still be able to specify instance-specific info just in case it turns
      out to be applicable.
      
      Finally, up to now, the parser for virtualport has always generated a
      random instanceid/interfaceid when appropriate, making it impossible
      to leave it blank (which is what's required for virtualports within a
      network/portprofile definition).
      
      This patch modifies the parser and formatter of the <virtualport>
      element in the following ways:
      
      * because most of the attributes in a virNetDevVPortProfile are fixed
        size binary data with no reserved values, there is no way to embed a
        "this value wasn't specified" sentinel into the existing data. To
        solve this problem, the new *_specified fields in the
        virNetDevVPortProfile object that were added in a previous patch of
        this series are now set when the corresponding attribute is present
        during the parse.
      
      * allow parsing/formatting a <virtualport> that has no type set. In
        this case, all fields are settable, but all are also optional.
      
      * add a GENERATE_MISSING_DEFAULTS flag to the parser - if this flag is
        set and an instanceid/interfaceid is expected but not provided, a
        random one will be generated. This was previously the default
        behavior, but is now done only for virtualports inside an
        <interface> definition, not for those in <network> or <portgroup>.
      
      * add a REQUIRE_ALL_ATTRIBUTES flag to the parser - if this flag is
        set the parser will call the new
        virNetDevVPortProfileCheckComplete() functions at the end of the
        parser to check for any missing attributes (based on type), and
        return failure if anything is missing. This used to be default
        behavior. Now it is only used for the virtualport defined inside an
        interface's <actual> element (by the time you've figured out the
        contents of <actual>, you should have all the necessary data to fill
        in the entire virtualport)
      
      * add a REQUIRE_TYPE flag to the parser - if this flag is set, the
        parser will return an error if the virtualport has no type
        attribute. This also was previously the default behavior, but isn't
        needed in the case of the virtualport for a type='network' interface
        (i.e. the exact type isn't yet known), or the virtualport of a
        portgroup (i.e. the portgroup just has modifiers for the network's
        virtualport, which *does* require a type) - in those cases, the
        check will be done at domain startup, once the final virtualport is
        assembled (this is handled in the next patch).
      4af3cbaf
  18. 10 8月, 2012 1 次提交
    • M
      esx: Implement network driver · b8fa5fd0
      Matthias Bolte 提交于
      An ESX server has one or more PhysicalNics that represent the actual
      hardware NICs. Those can be listed via the interface driver.
      
      A libvirt virtual network is mapped to a HostVirtualSwitch. On the
      physical side a HostVirtualSwitch can be connected to PhysicalNics.
      On the virtual side a HostVirtualSwitch has HostPortGroups that are
      mapped to libvirt virtual network's portgroups. Typically there is
      HostPortGroups named 'VM Network' that is used to connect virtual
      machines to a HostVirtualSwitch. A second HostPortGroup typically
      named 'Management Network' is used to connect the hypervisor itself
      to the HostVirtualSwitch. This one is not mapped to a libvirt virtual
      network's portgroup. There can be more HostPortGroups than those
      typical two on a HostVirtualSwitch.
      
               +---------------+-------------------+
         ...---|               |                   |   +-------------+
               | HostPortGroup |                   |---| PhysicalNic |
               |   VM Network  |                   |   |    vmnic0   |
         ...---|               |                   |   +-------------+
               +---------------+ HostVirtualSwitch |
                               |     vSwitch0      |
               +---------------+                   |
               | HostPortGroup |                   |
         ...---|   Management  |                   |
               |    Network    |                   |
               +---------------+-------------------+
      
      The virtual counterparts of the PhysicalNic is the HostVirtualNic for
      the hypervisor and the VirtualEthernetCard for the virtual machines
      that are grouped into HostPortGroups.
      
         +---------------------+   +---------------+---...
         | VirtualEthernetCard |---|               |
         +---------------------+   | HostPortGroup |
         +---------------------+   |   VM Network  |
         | VirtualEthernetCard |---|               |
         +---------------------+   +---------------+
                                                   |
                                   +---------------+
         +---------------------+   | HostPortGroup |
         |    HostVirtualNic   |---|   Management  |
         +---------------------+   |    Network    |
                                   +---------------+---...
      
      The currently implemented network driver can list, define and undefine
      HostVirtualSwitches including HostPortGroups for virtual machines.
      Existing HostVirtualSwitches cannot be edited yet. This will be added
      in a followup patch.
      b8fa5fd0
  19. 27 7月, 2012 1 次提交
    • E
      maint: don't permit format strings without % · 768007ae
      Eric Blake 提交于
      Any time we have a string with no % passed through gettext, a
      translator can inject a % to cause a stack overread.  When there
      is nothing to format, it's easier to ask for a string that cannot
      be used as a formatter, by using a trivial "%s" format instead.
      
      In the past, we have used --disable-nls to catch some of the
      offenders, but that doesn't get run very often, and many more
      uses have crept in.  Syntax check to the rescue!
      
      The syntax check can catch uses such as
      virReportError(code,
                     _("split "
                       "string"));
      by using a sed script to fold context lines into one pattern
      space before checking for a string without %.
      
      This patch is just mechanical insertion of %s; there are probably
      several messages touched by this patch where we would be better
      off giving the user more information than a fixed string.
      
      * cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
      * src/datatypes.c (virUnrefConnect, virGetDomain)
      (virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
      (virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
      (virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
      (virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
      (virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
      * src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
      (lxcDomainGetBlkioParameters): Likewise.
      * src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
      (virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
      Likewise.
      * src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
      (virNetworkDefParseXML): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
      Likewise.
      * src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
      (virNWFilterVarAccessParse): Likewise.
      * src/libvirt.c (virDomainSave, virDomainSaveFlags)
      (virDomainRestore, virDomainRestoreFlags)
      (virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
      (virDomainCoreDump, virDomainGetXMLDesc)
      (virDomainMigrateVersion1, virDomainMigrateVersion2)
      (virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
      (virStreamSendAll, virStreamRecvAll)
      (virDomainSnapshotGetXMLDesc): Likewise.
      * src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
      (virNWFilterDHCPSnoopReq): Likewise.
      * src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
      * src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
      * src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
      * src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
      (qemuBuildCommandLine): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
      * src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
      Likewise.
      * src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
      (virNetSocketSendFD, virNetSocketRecvFD): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskBuildPool): Likewise.
      * src/storage/storage_backend_fs.c
      (virStorageBackendFileSystemProbe)
      (virStorageBackendFileSystemBuild): Likewise.
      * src/storage/storage_backend_rbd.c
      (virStorageBackendRBDOpenRADOSConn): Likewise.
      * src/storage/storage_driver.c (storageVolumeResize): Likewise.
      * src/test/test_driver.c (testInterfaceChangeBegin)
      (testInterfaceChangeCommit, testInterfaceChangeRollback):
      Likewise.
      * src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
      * src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
      Likewise.
      * src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
      (xenFormatXM): Likewise.
      768007ae