From: Joao Martins <joao.m.martins@oracle.com>
To: Jim Fehlig <jfehlig@suse.com>
Cc: libvir-list@redhat.com, xen-devel@lists.xen.org
Subject: Re: [PATCH v3 3/8] libxl: implement virDomainInterfaceStats
Date: Tue, 17 Nov 2015 11:31:03 +0000 [thread overview]
Message-ID: <564B0FF7.6070506@oracle.com> (raw)
In-Reply-To: <564A9571.8000609@suse.com>
On 11/17/2015 02:48 AM, Jim Fehlig wrote:
> On 11/13/2015 06:14 AM, Joao Martins wrote:
>> Introduce support for domainInterfaceStats API call for querying
>> network interface statistics. Consequently it also enables the
>> use of `virsh domifstat <dom> <interface name>` command.
>>
>> After succesful guest creation we fill the network
>> interfaces names based on domain, device id and append suffix
>> if it's emulated in the following form: vif<domid>.<devid>[-emu]. Because
>> we need the devid from domain config (which is filled by libxl on domain
>> create) we cannot do generate the names in console callback.
>
> Bummer, but see below.
>
>> On domain
>> cleanup we also clear ifname, in case it was set by libvirt (i.e.
>> being prefixed with "vif"). We also skip these two steps in case the name
>> of the interface was manually inserted by the adminstrator.
>>
>> For getting the interface statistics we resort to virNetInterfaceStats
>> and let libvirt handle the platform specific nits. Note that the latter
>> is not yet supported in FreeBSD.
>>
>> Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
>> ---
>> Changes since v2:
>> - Clear ifname if it's autogenerated, since otherwise will persist
>> on successive domain starts. Change commit message reflecting this
>> change.
>>
>> Changes since v1:
>> - Fill <virDomainNetDef>.ifname after domain start with generated
>> name from libxl based on domain id and devid returned by libxl.
>> After that path validation don interfaceStats is enterily based
>> on ifname pretty much like the other drivers.
>> - Modify commit message reflecting the changes mentioned in
>> the previous item.
>> - Bump version to 1.2.22
>> ---
>> src/libxl/libxl_domain.c | 26 ++++++++++++++++++++++++++
>> src/libxl/libxl_driver.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 74 insertions(+)
>>
>> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
>> index 40dcea1..adb4563 100644
>> --- a/src/libxl/libxl_domain.c
>> +++ b/src/libxl/libxl_domain.c
>> @@ -728,6 +728,17 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
>> }
>> }
>>
>> + if ((vm->def->nnets)) {
>> + ssize_t i;
>> +
>> + for (i = 0; i < vm->def->nnets; i++) {
>> + virDomainNetDefPtr net = vm->def->nets[i];
>> +
>> + if (STRPREFIX(net->ifname, "vif"))
>> + VIR_FREE(net->ifname);
>
> Would not be nice if user-specified ifname started with "vif" :-).
>
I think QEMU they do in a similar way, in case, specified interfaces started
with a prefix that is solely for autogenerated interface naming. Would you
prefer removing it? The problem with removing this is that ifname would persist
on the XML, and future domainStart would use the old value.
>> + }
>> + }
>> +
>> if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) > 0) {
>> if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
>> VIR_DEBUG("Failed to remove domain XML for %s", vm->def->name);
>> @@ -901,6 +912,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
>> virDomainDefPtr def = NULL;
>> virObjectEventPtr event = NULL;
>> libxlSavefileHeader hdr;
>> + ssize_t i;
>> int ret = -1;
>> uint32_t domid = 0;
>> char *dom_xml = NULL;
>> @@ -1023,6 +1035,20 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
>> */
>> vm->def->id = domid;
>>
>> + for (i = 0; i < vm->def->nnets; i++) {
>> + virDomainNetDefPtr net = vm->def->nets[i];
>> + libxl_device_nic *x_nic = &d_config.nics[i];
>> + const char *suffix =
>> + x_nic->nictype != LIBXL_NIC_TYPE_VIF ? "-emu" : "";
>> +
>> + if (net->ifname)
>> + continue;
>> +
>> + if (virAsprintf(&net->ifname, "vif%d.%d%s",
>> + domid, x_nic->devid, suffix) < 0)
>> + continue;
>> + }
>> +
>
> This could be done in the callback, if we added the libxl_domain_config object
> to the libxlDomainObjPrivate struct. Currently we create, use, and dispose the
> object in libxlDomainStart, but it would probably be useful keep the object
> around while the domain is active.
That's a good idea. This chunk would definitely be better placed in ConsoleCallback.
> Actually, you could directly use the object
> in libxlDomainInterfaceStats if it was included in the libxlDomainObjPrivate
> struct. I realize it is a bit more work than this or the V1 approach, but what
> do you think about it?
Huum, IIUC we would be doing similar to V1, with the difference that we would do
it more reliably by knowning devid in advance through usage of
libxl_domain_config. The good thing about this version though is that it
simplifies things simple for interfaceStats and getAllDomainStats, since all it
takes is just to compare against the interface name we calculated beforehand on
domain start. Moreover we can actually see what interfaces each domain has when
doing domiflist as a result of setting net->ifname (right now only "-" would
show up in the name). The only problem on the latter is the assumption on
domainCleanup in which all interfaces starting "vif" are assumed to be
autogenerated (since there is no flag/field to tell that on virDomainNetDef).
Cheers,
Joao
>
> Regards,
> Jim
>
next prev parent reply other threads:[~2015-11-17 11:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1447420488-5312-1-git-send-email-joao.m.martins@oracle.com>
2015-11-13 13:14 ` [PATCH v3 1/8] libxl: implement virDomainGetCPUStats Joao Martins
2015-11-13 13:14 ` [PATCH v3 2/8] libxl: implement virDomainMemorystats Joao Martins
2015-11-13 13:14 ` [PATCH v3 3/8] libxl: implement virDomainInterfaceStats Joao Martins
2015-11-13 13:14 ` [PATCH v3 4/8] util: add virDiskNameParse to handle disk and partition idx Joao Martins
2015-11-18 20:57 ` Jim Fehlig
2015-11-13 13:14 ` [PATCH v3 5/8] libxl: implement virDomainBlockStats Joao Martins
2015-11-13 13:14 ` [PATCH v3 6/8] libxl: implement virConnectGetAllDomainStats Joao Martins
2015-11-13 13:14 ` [PATCH v3 7/8] libxl: implement virDomainGetJobInfo Joao Martins
2015-11-13 13:14 ` [PATCH v3 8/8] libxl: implement virDomainGetJobStats Joao Martins
[not found] ` <1447420488-5312-4-git-send-email-joao.m.martins@oracle.com>
2015-11-17 2:48 ` [PATCH v3 3/8] libxl: implement virDomainInterfaceStats Jim Fehlig
[not found] ` <564A9571.8000609@suse.com>
2015-11-17 11:31 ` Joao Martins [this message]
2015-11-17 23:38 ` Jim Fehlig
[not found] ` <564BBA71.8000704@suse.com>
2015-11-18 18:14 ` Joao Martins
[not found] ` <1447420488-5312-2-git-send-email-joao.m.martins@oracle.com>
2015-11-17 2:59 ` [PATCH v3 1/8] libxl: implement virDomainGetCPUStats Jim Fehlig
[not found] ` <564A9815.9080705@suse.com>
2015-11-17 10:58 ` Joao Martins
2015-11-18 17:33 ` [libvirt] " Jim Fehlig
2015-11-18 18:18 ` Joao Martins
[not found] ` <1447420488-5312-3-git-send-email-joao.m.martins@oracle.com>
2015-11-17 2:53 ` [PATCH v3 2/8] libxl: implement virDomainMemorystats Jim Fehlig
2015-11-17 23:15 ` Jim Fehlig
[not found] ` <564BB51A.4090501@suse.com>
2015-11-18 18:05 ` Joao Martins
[not found] ` <564CBDD1.3060908@oracle.com>
2015-11-18 20:48 ` Jim Fehlig
2015-11-18 22:31 ` Konrad Rzeszutek Wilk
[not found] ` <1447420488-5312-6-git-send-email-joao.m.martins@oracle.com>
2015-11-18 19:01 ` [PATCH v3 5/8] libxl: implement virDomainBlockStats Jim Fehlig
[not found] ` <564CCAF4.80406@suse.com>
2015-11-19 13:46 ` Joao Martins
[not found] ` <1447420488-5312-7-git-send-email-joao.m.martins@oracle.com>
2015-11-18 22:03 ` [PATCH v3 6/8] libxl: implement virConnectGetAllDomainStats Jim Fehlig
[not found] ` <564CF595.5080602@suse.com>
2015-11-19 14:03 ` Joao Martins
[not found] ` <1447420488-5312-9-git-send-email-joao.m.martins@oracle.com>
2015-12-03 18:48 ` [PATCH v3 8/8] libxl: implement virDomainGetJobStats Jim Fehlig
[not found] ` <56608E76.3010908@suse.com>
2015-12-03 19:29 ` Joao Martins
[not found] ` <56609810.3090705@oracle.com>
2015-12-15 22:42 ` Jim Fehlig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=564B0FF7.6070506@oracle.com \
--to=joao.m.martins@oracle.com \
--cc=jfehlig@suse.com \
--cc=libvir-list@redhat.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.