Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Networking with hyperstart #399

Merged
merged 7 commits into from
Nov 21, 2016

Conversation

amshinde
Copy link
Contributor

No description provided.

@amshinde amshinde changed the title Networking hyper Networking with hyperstart Nov 14, 2016

return ( g_strdup_printf("ip=%s::%s:%s:%s:%s:off::",
ipv4_cfg->ip_address,
return ( g_strdup_printf("ip=:::%s:::%s::off::",
config->net.gateway,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function needs a check to ensure config != NULL before dereferencing. Also, I'd add checks on gateway and hostname to avoid (null) being returned as part of the string on error.

/*!
* Append qemu options for networking
*
* config \ref cc_oci_config.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both args need a \param in the function header.

* additional_args Array that will be appended
*/
static void
cc_oci_append_network_args(struct cc_oci_config *config,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check both params to ensure they are not NULL.

@@ -105,7 +79,7 @@ cc_oci_expand_netdev_cmdline(struct cc_oci_config *config, guint index) {
return g_strdup("");
}

#define QEMU_FMT_DEVICE "driver=virtio-net-pci,netdev=%s"
#define QEMU_FMT_DEVICE "driver=virtio-net-pci,bus=/pci-lite-host/pcie.0,addr=%x,netdev=%s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this bus a well-known address or something that is being "claimed"/allocated here? I think a comment would be useful to explain why this was added.

}
/* append additional args array */
for (int i = 0; i < extra_args_len; i++) {
gchar* arg = g_ptr_array_index(hypervisor_extra_args, i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be clearer if arg were const here.

* \param index Index into the array that was used for the qemu
* pcie address option as well
*/
gchar *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing \return.

/* Offset to add to the interface index for assigning the pci slot.
* First 3 slots are in use for pc-lite machine type
*/
#define PCI_OFFSET 4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any likelihood that qemu might change the number of slots it assigns itself? What are the first 3 slots used for specifically?

This looks like a potential maintenance issue, but I'm not sure how we can protect against future changes here? Hopefully, if qemu did change, we'd get errors logged in the hypervisor logs, but can we do better than that?

Copy link
Contributor Author

@amshinde amshinde Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jodh-intel The pci slots currently in use are:
PCI: slot 0 function 0 => in use by pci-lite-device
PCI: slot 1 function 0 => in use by PM_LITE
PCI: slot 2 function 0 => in use by virtio-9p-pci
PCI: slot 3 function 0 => in use by virtio-serial-pci

The first two 0 and 1 seem to be used by qemu for the pc-lite machine type, the last two are used by us for the 9p mount and for the virtual console respectively. I'll be updating the comments in the code to reflect this.

I am inclined to set the offset to a higher value (maybe 8) to take into account any available free slots being assigned by qemu or used by us in the future. What do you think?

( Slot 0 ref: https://github.com/01org/qemu-lite/blob/qemu-2.7-lite/hw/pci-host/pci_lite.c#L206
Slot 1 ref: https://github.com/01org/qemu-lite/blob/qemu-2.7-lite/hw/acpi/pm_lite.c#L302
These are part of qemu-lite changes submitted for pc-lite )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me. @anthonyzxu - do you have any comments on this strategy?

@amshinde - how about adding a g_debug() call where the value of PCI_OFFSET is logged (in cc_oci_expand_net_device_cmdline()?), so that if there is a future clash with qemu-lite, atleast there is a log entry to aid in debugging.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should correlate if this is at all affected/related to the PCI BAR scanning optimisations in the guest kernel as well - if you look at the guest kernel patches you'll find:

0006-probe-patch
407-pci-guest....

where we optimise the BAR scanning for the pc-lite machine, I believe to 4 slots presently, as we 'know' there is nothing beyond there ... or wasn't.

Indeed, it would be good to get @anthonyzxu input here.
(some of those two should really be merged ;-)


ipaddr_arr = json_array_new();

for (uint j = 0; j < g_slist_length(if_cfg->ipv4_addrs); j++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guint for consistency.

@jodh-intel
Copy link
Contributor

I'm seeing the dreaded "generic hyperstart error" testing this branch:

debug:writing message data to proxy socket: {"id":"hyper","data":{"hyperName":"startpod","data":{"hostname":"cb8f97ef7cae7078e50440a7d9b60e53634dc2352f0aa749973118a31da4ad58","containers":[],"shareDir":"rootfs","interfaces":[{"device":"enp0s4","newDeviceName":"eth0","ipAddresses":[{"ipAddress":"172.17.0.2","netMask":"255.255.0.0"}]}]}}}
debug:message read from proxy socket: {"success":false,"error":"hyperstart returned an error"}

@amshinde
Copy link
Contributor Author

@jodh-intel Looks like your image does not have patch for multiple ip addresses. Looking at our package in Clear, this seems to have fallen through. I'll add that to the image.

Its sufficient to pass just the address of the array instead of
pointer to the address.

Signed-off-by: Archana Shinde <[email protected]>
The args to be appended should be dynamically allocated before adding to
additional args array. The strings would be freed when the array is freed.

Signed-off-by: Archana Shinde <[email protected]>
Assigning a pcie address to netdev device, ensures that the interface gets
a unique name within the VM. This enables support for multiple interfaces
by allowing an interface to be identified and configured based on its
unique name mapped to pcie address.

Signed-off-by: Archana Shinde <[email protected]>
…rfaces.

Get rid of the network substitution variables and append the
networking qemu options instead.

Signed-off-by: Archana Shinde <[email protected]>
Configuration for multiple interfaces and multiple ip addresses for an
interface can be passed while starting a POD.Remove the interface
configuration from the kernel parameters.

Signed-off-by: Archana Shinde <[email protected]>
@amshinde
Copy link
Contributor Author

@jodh-intel I have addressed your review comments.

@jodh-intel
Copy link
Contributor

jodh-intel commented Nov 18, 2016

lgtm.

Approved with PullApprove

@dlespiau
Copy link
Contributor

dlespiau commented Nov 19, 2016

Haven't gone into details, but the general flow looks good to me. Better have it in the branch for all to test than in a PR.

lgtm

Approved with PullApprove

@chavafg
Copy link
Contributor

chavafg commented Nov 19, 2016

qa-passed

Approved with PullApprove

@jodh-intel jodh-intel merged commit f3287a2 into intel:redesign-for-cc-2.1 Nov 21, 2016
@amshinde amshinde deleted the networking-hyper branch January 19, 2017 23:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants