Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
On Wed, Sep 09, 2015 at 10:16:33 +0200, Michal Privoznik wrote: > On 08.09.2015 14:10, Peter Krempa wrote: > > On Wed, Sep 02, 2015 at 17:58:19 +0200, Michal Privoznik wrote: > >> From: Lin Ma> >> > >> Format & output more detailed information about networked source > >> > >> e.g: The output without the patch: > >> $ virsh domblklist $DOMAIN --details > >> Type Device Target Source > >> > >> networkdisk vdatest-pool/image > >> networkdisk vdbiqn.2015-08.org.example:sn01/0 > >> networkdisk vdc/image.raw > >> networkdisk vdd- > >> networkdisk vde- > >> networkdisk vdfimage1 > >> networkdisk vdgtest-volume/image.raw > >> > >> The output with the patch: > >> $ virsh domblklist $DOMAIN --details > >> Type Device Target Source > >> > >> networkdisk vda > >> rbd://monitor1.example.org:6321/test-pool/image > > > > One other thing to note is that RBD volumes may have multiple hosts, > > which is not taken into account by the above format ... > > > >> networkdisk vdb > >> iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 > >> networkdisk vdchttp://192.168.124.200:80/image.raw > >> networkdisk vddnbd+unix:///var/run/nbdsock > >> networkdisk vdenbd://192.168.124.200:12345 > >> networkdisk vdfsheepdog://192.168.124.200:6000/image1 > >> networkdisk vdg > >> gluster://192.168.124.200/test-volume/image.raw > > > > ... and gluster volumes will possibly have multiple sources too. > > > Do you have any bright idea how to express that? E.g. something like: > > gluster://{hostA, hostB, hostC}/test-volume/image.raw > rbd://{hostD, hostE}/test-pool/image Gluster and RBD also needs to expose host:port combinations possibly. > > can work? I'd refrain from strings formatted as URIs or anything hypervisor specific (eg QEMU source string for RBD). I'd rather see a human formatted string since this is a human readable output: "hosts: host1.example.com:123 host2.example.com:345 path: test-volume/image.raw" Scripts definitely have better time parsing the XML here. Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
On 08.09.2015 14:10, Peter Krempa wrote: > On Wed, Sep 02, 2015 at 17:58:19 +0200, Michal Privoznik wrote: >> From: Lin Ma>> >> Format & output more detailed information about networked source >> >> e.g: The output without the patch: >> $ virsh domblklist $DOMAIN --details >> Type Device Target Source >> >> networkdisk vdatest-pool/image >> networkdisk vdbiqn.2015-08.org.example:sn01/0 >> networkdisk vdc/image.raw >> networkdisk vdd- >> networkdisk vde- >> networkdisk vdfimage1 >> networkdisk vdgtest-volume/image.raw >> >> The output with the patch: >> $ virsh domblklist $DOMAIN --details >> Type Device Target Source >> >> networkdisk vda >> rbd://monitor1.example.org:6321/test-pool/image > > One other thing to note is that RBD volumes may have multiple hosts, > which is not taken into account by the above format ... > >> networkdisk vdb >> iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 >> networkdisk vdchttp://192.168.124.200:80/image.raw >> networkdisk vddnbd+unix:///var/run/nbdsock >> networkdisk vdenbd://192.168.124.200:12345 >> networkdisk vdfsheepdog://192.168.124.200:6000/image1 >> networkdisk vdg >> gluster://192.168.124.200/test-volume/image.raw > > ... and gluster volumes will possibly have multiple sources too. Do you have any bright idea how to express that? E.g. something like: gluster://{hostA, hostB, hostC}/test-volume/image.raw rbd://{hostD, hostE}/test-pool/image can work? Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
On Wed, Sep 02, 2015 at 17:58:19 +0200, Michal Privoznik wrote: > From: Lin Ma> > Format & output more detailed information about networked source > > e.g: The output without the patch: > $ virsh domblklist $DOMAIN --details > Type Device Target Source > > networkdisk vdatest-pool/image > networkdisk vdbiqn.2015-08.org.example:sn01/0 > networkdisk vdc/image.raw > networkdisk vdd- > networkdisk vde- > networkdisk vdfimage1 > networkdisk vdgtest-volume/image.raw > > The output with the patch: > $ virsh domblklist $DOMAIN --details > Type Device Target Source > > networkdisk vda > rbd://monitor1.example.org:6321/test-pool/image One other thing to note is that RBD volumes may have multiple hosts, which is not taken into account by the above format ... > networkdisk vdb > iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 > networkdisk vdchttp://192.168.124.200:80/image.raw > networkdisk vddnbd+unix:///var/run/nbdsock > networkdisk vdenbd://192.168.124.200:12345 > networkdisk vdfsheepdog://192.168.124.200:6000/image1 > networkdisk vdg > gluster://192.168.124.200/test-volume/image.raw ... and gluster volumes will possibly have multiple sources too. > > Signed-off-by: Lin Ma > Signed-off-by: Michal Privoznik > --- > tools/virsh-domain-monitor.c | 64 > > 1 file changed, 59 insertions(+), 5 deletions(-) Peter signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
在 2015年09月08日 20:10, Peter Krempa 写道: On Wed, Sep 02, 2015 at 17:58:19 +0200, Michal Privoznik wrote: From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image One other thing to note is that RBD volumes may have multiple hosts, which is not taken into account by the above format ... Yes, It may have multiple hosts for rbd. My original idea was adding more specific info to details option for networked source and make the output more nice. It has nothing to do with functional changes, So it just shows the first host. Should we bring all of hosts to here? networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw ... and gluster volumes will possibly have multiple sources too. Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- tools/virsh-domain-monitor.c | 64 1 file changed, 59 insertions(+), 5 deletions(-) Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
在 2015年09月04日 18:53, John Ferlan 写道: On 09/04/2015 04:26 AM, Michal Privoznik wrote: On 03.09.2015 22:47, John Ferlan wrote: On 09/02/2015 11:58 AM, Michal Privoznik wrote: From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw Is the goal to just format in some "standard" format or to use the format that would be used by qemu in the command line? While it's the former, I think we should at least cover asses and document that these strings have no special meaning and can change later if we find a better way of expressing them. Or should we? Since the Source path is provided whether or not --details is supplied, I guess I'd be concerned if we've ever made any "guarantees" about the format of the output for default displays and what a change like this could break. I can tell you that when there was a change to add an extra leading space to some display output, there were virt-tests that just began failing because the difference between seeing "# ..." and " # ..." in the output wasn't handled properly. Anyway, the man page says: Print a table showing the brief information of all block devices associated with I. If I<--inactive> is specified, query the block devices that will be used on the next boot, rather than those currently in use by a running domain. If I<--details> is specified, disk type and device value will also be printed. Other contexts that require a block device name (such as I or I for disk snapshots) will accept either target or unique source names printed by this command. For networked storage, The domblkinfo or snapshot-create won't work with target or source name, Should we add something to mention it? Which a naive user could be led to believe that by grabbing the value in the "Source" column (such as "nbd://192.168.124.200:12345") they could feed that into "virsh domblkinfo $dom $Source" and it would work. In fact, someone that can write scripts better than I could be currently stripping that last field off and using it as input to their domblkinfo command in order to get the Capacity, Allocation, Physical values in some form. Yes, of course those would be "broken" today for network. Since the test environment is already set up, Lin Ma can you at least see what happens for the various formats if one just cut-n-pasted that column for domblkinfo? One option/adjustment perhaps is we only print the "details" of the network source if --details is provided (and document it). Or we could add something like the following after the first sentence to virsh.pod (for the CYA needs): For networked storage the Source displayed uses the domain XML to extract source protocol, transport, host name, host port, and source name or socket data in order to format and display in a standard manner starting with the protocol, such as: "$protocol[+$transport]://[$host:$port][{/$name|:$socket}]" I tend to : 1. Add above explaination to virsh.pod. 2. Mention in virsh.pod that the command require a block device name says domblkinfo or snapshot-create can't accept the target or source name for networked storage. 3. Print the whole url info for networked storage if --details is provided. [Done] May I have your ideas? or anyelse suggestions? That could be ugly difficult to display and I don't see any other current example in a quick scan through virsh.pod. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
在 2015年09月04日 18:53, John Ferlan 写道: On 09/04/2015 04:26 AM, Michal Privoznik wrote: On 03.09.2015 22:47, John Ferlan wrote: On 09/02/2015 11:58 AM, Michal Privoznik wrote: From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw Is the goal to just format in some "standard" format or to use the format that would be used by qemu in the command line? While it's the former, I think we should at least cover asses and document that these strings have no special meaning and can change later if we find a better way of expressing them. Or should we? Since the Source path is provided whether or not --details is supplied, I guess I'd be concerned if we've ever made any "guarantees" about the format of the output for default displays and what a change like this could break. I can tell you that when there was a change to add an extra leading space to some display output, there were virt-tests that just began failing because the difference between seeing "# ..." and " # ..." in the output wasn't handled properly. Anyway, the man page says: Print a table showing the brief information of all block devices associated with I. If I<--inactive> is specified, query the block devices that will be used on the next boot, rather than those currently in use by a running domain. If I<--details> is specified, disk type and device value will also be printed. Other contexts that require a block device name (such as I or I for disk snapshots) will accept either target or unique source names printed by this command. Which a naive user could be led to believe that by grabbing the value in the "Source" column (such as "nbd://192.168.124.200:12345") they could feed that into "virsh domblkinfo $dom $Source" and it would work. In fact, someone that can write scripts better than I could be currently stripping that last field off and using it as input to their domblkinfo command in order to get the Capacity, Allocation, Physical values in some form. Yes, of course those would be "broken" today for network. Since the test environment is already set up, Lin Ma can you at least see what happens for the various formats if one just cut-n-pasted that column for domblkinfo? For networked disks which were attached directly, domblkinfo can't recognize them: virsh domblkinfo $dom $Target will output the error message with related protocol: "error: internal error: missing storage backend for network files using %s protocol" virsh domblkinfo $dom $Source will output "error: invalid argument: invalid path $Source not assigned to domain" One option/adjustment perhaps is we only print the "details" of the network source if --details is provided (and document it). Or we could add something like the following after the first sentence to virsh.pod (for the CYA needs): For networked storage the Source displayed uses the domain XML to extract source protocol, transport, host name, host port, and source name or socket data in order to format and display in a standard manner starting with the protocol, such as: "$protocol[+$transport]://[$host:$port][{/$name|:$socket}]" That could be ugly difficult to display and I don't see any other current example in a quick scan through virsh.pod. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
On 09/04/2015 04:26 AM, Michal Privoznik wrote: > On 03.09.2015 22:47, John Ferlan wrote: >> >> >> On 09/02/2015 11:58 AM, Michal Privoznik wrote: >>> From: Lin Ma>>> >>> Format & output more detailed information about networked source >>> >>> e.g: The output without the patch: >>> $ virsh domblklist $DOMAIN --details >>> Type Device Target Source >>> >>> networkdisk vdatest-pool/image >>> networkdisk vdbiqn.2015-08.org.example:sn01/0 >>> networkdisk vdc/image.raw >>> networkdisk vdd- >>> networkdisk vde- >>> networkdisk vdfimage1 >>> networkdisk vdgtest-volume/image.raw >>> >>> The output with the patch: >>> $ virsh domblklist $DOMAIN --details >>> Type Device Target Source >>> >>> networkdisk vda >>> rbd://monitor1.example.org:6321/test-pool/image >>> networkdisk vdb >>> iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 >>> networkdisk vdchttp://192.168.124.200:80/image.raw >>> networkdisk vddnbd+unix:///var/run/nbdsock >>> networkdisk vdenbd://192.168.124.200:12345 >>> networkdisk vdfsheepdog://192.168.124.200:6000/image1 >>> networkdisk vdg >>> gluster://192.168.124.200/test-volume/image.raw >> >> Is the goal to just format in some "standard" format or to use the >> format that would be used by qemu in the command line? > > While it's the former, I think we should at least cover asses and > document that these strings have no special meaning and can change later > if we find a better way of expressing them. Or should we? > Since the Source path is provided whether or not --details is supplied, I guess I'd be concerned if we've ever made any "guarantees" about the format of the output for default displays and what a change like this could break. I can tell you that when there was a change to add an extra leading space to some display output, there were virt-tests that just began failing because the difference between seeing "# ..." and " # ..." in the output wasn't handled properly. Anyway, the man page says: Print a table showing the brief information of all block devices associated with I. If I<--inactive> is specified, query the block devices that will be used on the next boot, rather than those currently in use by a running domain. If I<--details> is specified, disk type and device value will also be printed. Other contexts that require a block device name (such as I or I for disk snapshots) will accept either target or unique source names printed by this command. Which a naive user could be led to believe that by grabbing the value in the "Source" column (such as "nbd://192.168.124.200:12345") they could feed that into "virsh domblkinfo $dom $Source" and it would work. In fact, someone that can write scripts better than I could be currently stripping that last field off and using it as input to their domblkinfo command in order to get the Capacity, Allocation, Physical values in some form. Yes, of course those would be "broken" today for network. Since the test environment is already set up, Lin Ma can you at least see what happens for the various formats if one just cut-n-pasted that column for domblkinfo? One option/adjustment perhaps is we only print the "details" of the network source if --details is provided (and document it). Or we could add something like the following after the first sentence to virsh.pod (for the CYA needs): For networked storage the Source displayed uses the domain XML to extract source protocol, transport, host name, host port, and source name or socket data in order to format and display in a standard manner starting with the protocol, such as: "$protocol[+$transport]://[$host:$port][{/$name|:$socket}]" That could be ugly difficult to display and I don't see any other current example in a quick scan through virsh.pod. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
在 2015年09月04日 18:53, John Ferlan 写道: On 09/04/2015 04:26 AM, Michal Privoznik wrote: On 03.09.2015 22:47, John Ferlan wrote: On 09/02/2015 11:58 AM, Michal Privoznik wrote: From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw Is the goal to just format in some "standard" format or to use the format that would be used by qemu in the command line? While it's the former, I think we should at least cover asses and document that these strings have no special meaning and can change later if we find a better way of expressing them. Or should we? Since the Source path is provided whether or not --details is supplied, I guess I'd be concerned if we've ever made any "guarantees" about the format of the output for default displays and what a change like this could break. I can tell you that when there was a change to add an extra leading space to some display output, there were virt-tests that just began failing because the difference between seeing "# ..." and " # ..." in the output wasn't handled properly. Anyway, the man page says: Print a table showing the brief information of all block devices associated with I. If I<--inactive> is specified, query the block devices that will be used on the next boot, rather than those currently in use by a running domain. If I<--details> is specified, disk type and device value will also be printed. Other contexts that require a block device name (such as I or I for disk snapshots) will accept either target or unique source names printed by this command. Which a naive user could be led to believe that by grabbing the value in the "Source" column (such as "nbd://192.168.124.200:12345") they could feed that into "virsh domblkinfo $dom $Source" and it would work. In fact, someone that can write scripts better than I could be currently stripping that last field off and using it as input to their domblkinfo command in order to get the Capacity, Allocation, Physical values in some form. Yes, of course those would be "broken" today for network. Since the test environment is already set up, Lin Ma can you at least see what happens for the various formats if one just cut-n-pasted that column for domblkinfo? Because China are in special holidays during these days, It's not convenient to access my storage environment that in server room, So I'll test domblkinfo for $Source next week. but I guess the result are negative because of the unrecognized url format of $Source. One option/adjustment perhaps is we only print the "details" of the network source if --details is provided (and document it). Or we could add something like the following after the first sentence to virsh.pod (for the CYA needs): For networked storage the Source displayed uses the domain XML to extract source protocol, transport, host name, host port, and source name or socket data in order to format and display in a standard manner starting with the protocol, such as: "$protocol[+$transport]://[$host:$port][{/$name|:$socket}]" That could be ugly difficult to display and I don't see any other current example in a quick scan through virsh.pod. John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
Just tested the patch, It works well. The changes makes more sense, Thanks for helping me to improve the patch! 在 2015年09月02日 23:58, Michal Privoznik 写道: From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- tools/virsh-domain-monitor.c | 64 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d4e500b..6446549 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -486,10 +486,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) xmlNodePtr *disks = NULL; size_t i; bool details = false; +virBuffer buf = VIR_BUFFER_INITIALIZER; char *type = NULL; char *device = NULL; char *target = NULL; char *source = NULL; +char *protocol = NULL; +char *transport = NULL; +char *host_name = NULL; +char *host_port = NULL; +char *socket = NULL; +char *name = NULL; if (vshCommandOptBool(cmd, "inactive")) flags |= VIR_DOMAIN_XML_INACTIVE; @@ -536,11 +543,45 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "unable to query block list"); goto cleanup; } -source = virXPathString("string(./source/@file" -"|./source/@dev" -"|./source/@dir" -"|./source/@name" -"|./source/@volume)", ctxt); +if (type && STREQ(type, "network")) { +protocol = virXPathString("string(./source/@protocol)", ctxt); +name = virXPathString("string(./source/@name)", ctxt); +transport = virXPathString("string(./source/host/@transport)", ctxt); +socket = virXPathString("string(./source/host/@socket)", ctxt); +host_name = virXPathString("string(./source/host/@name)", ctxt); +host_port = virXPathString("string(./source/host/@port)", ctxt); + +virBufferAddStr(, protocol); + +if (transport) +virBufferAsprintf(, "+%s", transport); +virBufferAddLit(, "://"); +if (host_name) { +virBufferAddStr(, host_name); +if (host_port) +virBufferAsprintf(, ":%s", host_port); +} +if (name) { +if (!STRPREFIX(name, "/")) +virBufferAddChar(, '/'); +virBufferAddStr(, name); +} else if (socket) { +if (!STRPREFIX(socket, "/")) +virBufferAddChar(, '/'); +virBufferAddStr(, socket); +} +if (virBufferError()) { +virReportOOMError(); +goto cleanup; +} +source = virBufferContentAndReset(); +} else { +source = virXPathString("string(./source/@file" +"|./source/@dev" +"|./source/@dir" +"|./source/@name" +"|./source/@volume)", ctxt); +} if (details) { vshPrint(ctl, "%-10s %-10s %-10s %s\n", type, device, target, source ? source : "-"); @@ -548,6 +589,12 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-10s %s\n", target, source ? source : "-"); } +VIR_FREE(name); +VIR_FREE(socket); +VIR_FREE(host_port); +VIR_FREE(host_name); +VIR_FREE(transport); +VIR_FREE(protocol);
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
On 03.09.2015 22:47, John Ferlan wrote: > > > On 09/02/2015 11:58 AM, Michal Privoznik wrote: >> From: Lin Ma>> >> Format & output more detailed information about networked source >> >> e.g: The output without the patch: >> $ virsh domblklist $DOMAIN --details >> Type Device Target Source >> >> networkdisk vdatest-pool/image >> networkdisk vdbiqn.2015-08.org.example:sn01/0 >> networkdisk vdc/image.raw >> networkdisk vdd- >> networkdisk vde- >> networkdisk vdfimage1 >> networkdisk vdgtest-volume/image.raw >> >> The output with the patch: >> $ virsh domblklist $DOMAIN --details >> Type Device Target Source >> >> networkdisk vda >> rbd://monitor1.example.org:6321/test-pool/image >> networkdisk vdb >> iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 >> networkdisk vdchttp://192.168.124.200:80/image.raw >> networkdisk vddnbd+unix:///var/run/nbdsock >> networkdisk vdenbd://192.168.124.200:12345 >> networkdisk vdfsheepdog://192.168.124.200:6000/image1 >> networkdisk vdg >> gluster://192.168.124.200/test-volume/image.raw > > Is the goal to just format in some "standard" format or to use the > format that would be used by qemu in the command line? While it's the former, I think we should at least cover asses and document that these strings have no special meaning and can change later if we find a better way of expressing them. Or should we? Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
On 09/02/2015 11:58 AM, Michal Privoznik wrote: > From: Lin Ma> > Format & output more detailed information about networked source > > e.g: The output without the patch: > $ virsh domblklist $DOMAIN --details > Type Device Target Source > > networkdisk vdatest-pool/image > networkdisk vdbiqn.2015-08.org.example:sn01/0 > networkdisk vdc/image.raw > networkdisk vdd- > networkdisk vde- > networkdisk vdfimage1 > networkdisk vdgtest-volume/image.raw > > The output with the patch: > $ virsh domblklist $DOMAIN --details > Type Device Target Source > > networkdisk vda > rbd://monitor1.example.org:6321/test-pool/image > networkdisk vdb > iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 > networkdisk vdchttp://192.168.124.200:80/image.raw > networkdisk vddnbd+unix:///var/run/nbdsock > networkdisk vdenbd://192.168.124.200:12345 > networkdisk vdfsheepdog://192.168.124.200:6000/image1 > networkdisk vdg > gluster://192.168.124.200/test-volume/image.raw Is the goal to just format in some "standard" format or to use the format that would be used by qemu in the command line? If I look at the code in qemuBuildNetworkDriveURI, it seems there's a provision for nbd, sheepdog, and rbd to be "different" with nbd having my least favorite construct to read "if (!((multiple choice || constructs)))" It seems nbd can either have uri format with "://" found or a format such as "nbd:unix:$socket" or "nbd:$hostname:$port". It seems sheepdog doesn't have to have a $host value and thus would have just "sheepdog:$source-path". It seems rbd doesn't conform to any norm - good luck with that one! While I don't disagree this is better than what is currently provided, I worry whether all 'options' are technically correct given what we send to qemu or conversely what perhaps someone provided to qemu and we attached to (whether that's possible still currently I'm not sure). See also qemuParseNBDString, qemuParseRBDString, qemuParseGlusterString, etc from qemu_command.c BTW: If the goal is to just format it some consistent manner, then the code seems fine to me... John > > Signed-off-by: Lin Ma > Signed-off-by: Michal Privoznik > --- > tools/virsh-domain-monitor.c | 64 > > 1 file changed, 59 insertions(+), 5 deletions(-) > > diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c > index d4e500b..6446549 100644 > --- a/tools/virsh-domain-monitor.c > +++ b/tools/virsh-domain-monitor.c > @@ -486,10 +486,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) > xmlNodePtr *disks = NULL; > size_t i; > bool details = false; > +virBuffer buf = VIR_BUFFER_INITIALIZER; > char *type = NULL; > char *device = NULL; > char *target = NULL; > char *source = NULL; > +char *protocol = NULL; > +char *transport = NULL; > +char *host_name = NULL; > +char *host_port = NULL; > +char *socket = NULL; > +char *name = NULL; > > if (vshCommandOptBool(cmd, "inactive")) > flags |= VIR_DOMAIN_XML_INACTIVE; > @@ -536,11 +543,45 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) > vshError(ctl, "unable to query block list"); > goto cleanup; > } > -source = virXPathString("string(./source/@file" > -"|./source/@dev" > -"|./source/@dir" > -"|./source/@name" > -"|./source/@volume)", ctxt); > +if (type && STREQ(type, "network")) { > +protocol = virXPathString("string(./source/@protocol)", ctxt); > +name = virXPathString("string(./source/@name)", ctxt); > +transport = virXPathString("string(./source/host/@transport)", > ctxt); > +socket = virXPathString("string(./source/host/@socket)", ctxt); > +host_name = virXPathString("string(./source/host/@name)", ctxt); > +host_port = virXPathString("string(./source/host/@port)", ctxt); > + > +virBufferAddStr(, protocol); > + > +if (transport) > +virBufferAsprintf(, "+%s", transport); > +virBufferAddLit(, "://"); > +if (host_name) { > +virBufferAddStr(, host_name); > +if (host_port) > +virBufferAsprintf(, ":%s", host_port); > +} > +if (name) { > +if (!STRPREFIX(name, "/")) > +virBufferAddChar(, '/'); > +
Re: [libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
在 2015年09月04日 04:47, John Ferlan 写道: On 09/02/2015 11:58 AM, Michal Privoznik wrote: From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw Is the goal to just format in some "standard" format or to use the format that would be used by qemu in the command line? The former. It's just used to make the output of network disk more clear. If I look at the code in qemuBuildNetworkDriveURI, it seems there's a provision for nbd, sheepdog, and rbd to be "different" with nbd having my least favorite construct to read "if (!((multiple choice || constructs)))" It seems nbd can either have uri format with "://" found or a format such as "nbd:unix:$socket" or "nbd:$hostname:$port". It seems sheepdog doesn't have to have a $host value and thus would have just "sheepdog:$source-path". It seems rbd doesn't conform to any norm - good luck with that one! While I don't disagree this is better than what is currently provided, I worry whether all 'options' are technically correct given what we send to qemu or conversely what perhaps someone provided to qemu and we attached to (whether that's possible still currently I'm not sure). See also qemuParseNBDString, qemuParseRBDString, qemuParseGlusterString, etc from qemu_command.c BTW: If the goal is to just format it some consistent manner, then the code seems fine to me... John Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- tools/virsh-domain-monitor.c | 64 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d4e500b..6446549 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -486,10 +486,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) xmlNodePtr *disks = NULL; size_t i; bool details = false; +virBuffer buf = VIR_BUFFER_INITIALIZER; char *type = NULL; char *device = NULL; char *target = NULL; char *source = NULL; +char *protocol = NULL; +char *transport = NULL; +char *host_name = NULL; +char *host_port = NULL; +char *socket = NULL; +char *name = NULL; if (vshCommandOptBool(cmd, "inactive")) flags |= VIR_DOMAIN_XML_INACTIVE; @@ -536,11 +543,45 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "unable to query block list"); goto cleanup; } -source = virXPathString("string(./source/@file" -"|./source/@dev" -"|./source/@dir" -"|./source/@name" -"|./source/@volume)", ctxt); +if (type && STREQ(type, "network")) { +protocol = virXPathString("string(./source/@protocol)", ctxt); +name = virXPathString("string(./source/@name)", ctxt); +transport = virXPathString("string(./source/host/@transport)", ctxt); +socket = virXPathString("string(./source/host/@socket)", ctxt); +host_name = virXPathString("string(./source/host/@name)", ctxt); +host_port = virXPathString("string(./source/host/@port)", ctxt); + +virBufferAddStr(, protocol); + +if (transport) +virBufferAsprintf(, "+%s", transport); +virBufferAddLit(, "://"); +if (host_name) { +virBufferAddStr(, host_name); +if (host_port) +virBufferAsprintf(, ":%s", host_port); +} +if (name) { +if (!STRPREFIX(name, "/")) +virBufferAddChar(, '/'); +virBufferAddStr(, name); +} else if (socket) { +
[libvirt] [PATCH v2 2/2] virsh: Enhance the detailed output of domblklist for networked source
From: Lin MaFormat & output more detailed information about networked source e.g: The output without the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdatest-pool/image networkdisk vdbiqn.2015-08.org.example:sn01/0 networkdisk vdc/image.raw networkdisk vdd- networkdisk vde- networkdisk vdfimage1 networkdisk vdgtest-volume/image.raw The output with the patch: $ virsh domblklist $DOMAIN --details Type Device Target Source networkdisk vdarbd://monitor1.example.org:6321/test-pool/image networkdisk vdb iscsi://192.168.124.200:3260/iqn.2015-08.org.example:sn01/0 networkdisk vdchttp://192.168.124.200:80/image.raw networkdisk vddnbd+unix:///var/run/nbdsock networkdisk vdenbd://192.168.124.200:12345 networkdisk vdfsheepdog://192.168.124.200:6000/image1 networkdisk vdggluster://192.168.124.200/test-volume/image.raw Signed-off-by: Lin Ma Signed-off-by: Michal Privoznik --- tools/virsh-domain-monitor.c | 64 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d4e500b..6446549 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -486,10 +486,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) xmlNodePtr *disks = NULL; size_t i; bool details = false; +virBuffer buf = VIR_BUFFER_INITIALIZER; char *type = NULL; char *device = NULL; char *target = NULL; char *source = NULL; +char *protocol = NULL; +char *transport = NULL; +char *host_name = NULL; +char *host_port = NULL; +char *socket = NULL; +char *name = NULL; if (vshCommandOptBool(cmd, "inactive")) flags |= VIR_DOMAIN_XML_INACTIVE; @@ -536,11 +543,45 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "unable to query block list"); goto cleanup; } -source = virXPathString("string(./source/@file" -"|./source/@dev" -"|./source/@dir" -"|./source/@name" -"|./source/@volume)", ctxt); +if (type && STREQ(type, "network")) { +protocol = virXPathString("string(./source/@protocol)", ctxt); +name = virXPathString("string(./source/@name)", ctxt); +transport = virXPathString("string(./source/host/@transport)", ctxt); +socket = virXPathString("string(./source/host/@socket)", ctxt); +host_name = virXPathString("string(./source/host/@name)", ctxt); +host_port = virXPathString("string(./source/host/@port)", ctxt); + +virBufferAddStr(, protocol); + +if (transport) +virBufferAsprintf(, "+%s", transport); +virBufferAddLit(, "://"); +if (host_name) { +virBufferAddStr(, host_name); +if (host_port) +virBufferAsprintf(, ":%s", host_port); +} +if (name) { +if (!STRPREFIX(name, "/")) +virBufferAddChar(, '/'); +virBufferAddStr(, name); +} else if (socket) { +if (!STRPREFIX(socket, "/")) +virBufferAddChar(, '/'); +virBufferAddStr(, socket); +} +if (virBufferError()) { +virReportOOMError(); +goto cleanup; +} +source = virBufferContentAndReset(); +} else { +source = virXPathString("string(./source/@file" +"|./source/@dev" +"|./source/@dir" +"|./source/@name" +"|./source/@volume)", ctxt); +} if (details) { vshPrint(ctl, "%-10s %-10s %-10s %s\n", type, device, target, source ? source : "-"); @@ -548,6 +589,12 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-10s %s\n", target, source ? source : "-"); } +VIR_FREE(name); +VIR_FREE(socket); +VIR_FREE(host_port); +VIR_FREE(host_name); +VIR_FREE(transport); +VIR_FREE(protocol); VIR_FREE(source); VIR_FREE(target); VIR_FREE(device); @@ -557,10 +604,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: +