Conversation
|
@alicefr PTAL |
rbradford
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
I'm worried that changing the existing constants will break the ABI. We know about the alias rules in QEMU so please can we use them and add generic versions wherever appropriate.
Long term we could deprecate those that duplicated.
| NVDIMM DeviceDriver = "nvdimm" | ||
|
|
||
| // Virtio9P is the 9pfs device driver. | ||
| Virtio9P DeviceDriver = "virtio-9p-pci" |
There was a problem hiding this comment.
This will break the ABI. I think you should consider adding a new one called Virtio9PGeneric
| VirtioNet DeviceDriver = "virtio-net" | ||
|
|
||
| // VirtioNetPCI is the virt-io pci networking device driver. | ||
| VirtioNetPCI DeviceDriver = "virtio-net-pci" |
There was a problem hiding this comment.
There is no need to change this one as there is already a generic version.
| VirtioNetPCI DeviceDriver = "virtio-net" | ||
|
|
||
| // VirtioSerial is the serial device driver. | ||
| VirtioSerial DeviceDriver = "virtio-serial-pci" |
There was a problem hiding this comment.
Again I think you'll need to a VirtioSerialGeneric
qemu/qemu.go
Outdated
| VHostVSockPCI DeviceDriver = "vhost-vsock-pci" | ||
|
|
||
| // VHostVSockCCW is the vhost vsock ccw driver. | ||
| VHostVSockCCW DeviceDriver = "vhost-vsock-ccw" |
There was a problem hiding this comment.
Rather than add -ccw version add a generic version.
There was a problem hiding this comment.
for vhost-vsock generic version does not exist. But both vhost-vsock-ccw and vhost-vsock-pci exist hence I created a new device
|
|
||
| const ( | ||
| //VhostUserSCSI represents a SCSI vhostuser device type | ||
| VhostUserSCSI = "vhost-user-scsi-pci" |
There was a problem hiding this comment.
Can you add generic versions of this and those below rather than renaming.
|
@rbradford the cyclo is 16. I don't know how to reduce this to 15. Can you help me out here? |
|
|
||
| const ( | ||
| //VhostUserSCSI represents a SCSI vhostuser device type | ||
| VhostUserSCSI = "vhost-user-scsi-pci" |
There was a problem hiding this comment.
there is not alias in this case, add a variable as for vfio-pci
qemu/qemu.go
Outdated
| default: | ||
| return "" | ||
| } | ||
| } |
There was a problem hiding this comment.
I understand why you split it in 2 switches, but I personally don't like it. If the maintainers agree, I would rather put a variable virtioNet and vfio and and a if statement at the beginning. Something like this
var virtioNet = "virtio-net-pci"
var vfio = "vfio-pci"
if runtime.GOARCH == "s390x" {
virtioNet = "virtio-net-ccw"
vfio = "vfio-ccw"
}and substitue the string in the original switch with the variable
qemu/qemu.go
Outdated
|
|
||
| // VhostVSOCKCCW is the VSOCK vhost device type for s390x. | ||
| VhostVSOCKCCW = "vhost-vsock-ccw" | ||
|
|
There was a problem hiding this comment.
You can save some lines by adding a generic VhostVSOCK and assign the ccw value if the architecture is s390x
There was a problem hiding this comment.
Generic vhost-vsock does not exist but to avoid unnecessary duplication, we can set VhostVSOCKPCI to "vhost-vsock-ccw" on Z. Not sure if the maintainers want this.
qemu/qemu.go
Outdated
|
|
||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) | ||
| if runtime.GOARCH != "s390x" { | ||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) |
There was a problem hiding this comment.
I'd use the generic variable and remove this if-else statement
There was a problem hiding this comment.
Let's wait for @markdryan or @rbradford to comment here, but I'd be tempted to remove all these 390-specific if tests and create qemu_s390x.go like we do in the runtime:
To minimise code duplication, you can create generic functions and variables that all other arches can call.
There was a problem hiding this comment.
I think adding a new specific file for s390x is not necessary, there are not many points where arch specific if tests are used. But if you still insist I am okay with it.
qemu/qemu.go
Outdated
| Virtio9P = "virtio-9p" | ||
|
|
||
| } | ||
| } |
There was a problem hiding this comment.
Maybe also a short comment that on s390x the -pci devices don't properly work. That's why you introduce the init function
qemu/qemu_test.go
Outdated
| } | ||
| } | ||
|
|
||
| func init() { |
There was a problem hiding this comment.
The same as for the other init function. Add a short comment
|
@devimc PTAL |
qemu/qemu.go
Outdated
| } | ||
| } | ||
|
|
||
| var vfio = "vfio-pci" |
There was a problem hiding this comment.
please add this variable to the list of variables at the beginning of the file
qemu/qemu.go
Outdated
|
|
||
| deviceParam := fmt.Sprintf("vfio-pci,host=%s", vfioDev.BDF) | ||
| if runtime.GOARCH != "s390x" { | ||
| deviceParam = fmt.Sprintf("vfio-pci,host=%s", vfioDev.BDF) |
There was a problem hiding this comment.
I think this if..else condition is not needed since you can use the variable vfio, right?
There was a problem hiding this comment.
No vfio is not an available device
There was a problem hiding this comment.
sorry I don't understand why you can't do something like this
deviceParam = fmt.Sprintf("%s,host=%s", vfio, vfioDev.BDF)There was a problem hiding this comment.
might be I missed something, please help me to understand
There was a problem hiding this comment.
Other devices like virtio-net are alias to virtio-net-ccw on Z and virtio-net-pci on others. However, a similar alias for vfio does not exist. Hence this needs to be kept as is.
There was a problem hiding this comment.
So just writing 'vfio' would result in an error
There was a problem hiding this comment.
However, a similar alias for vfio does not exist
what do you mean?
At the beginning of the file you are declaring Vfio = "vfio-pci" but you change its value at init() if runtime.GOARCH == "s390x", I wonder if is possible to use theVfio variable or declare a new variable (like you did with VirtioSCSI) in order to rid of this if...else condition.
There was a problem hiding this comment.
let me update my example
deviceParam = fmt.Sprintf("%s,host=%s", Vfio, vfioDev.BDF)There was a problem hiding this comment.
yup that's possible... I thought you were asking me to change vfio-pci to generic vfio
qemu/qemu.go
Outdated
|
|
||
| devParams = append(devParams, fmt.Sprintf("virtio-scsi-pci,id=%s", scsiCon.ID)) | ||
| if runtime.GOARCH == "s390x" { | ||
| devParams = append(devParams, fmt.Sprintf("virtio-scsi-ccw,id=%s", scsiCon.ID)) |
There was a problem hiding this comment.
you can declare a variable for virtio-scsi-pci and change it value to virtio-scsi-ccw at at init()
|
@devimc @rbradford PTAL |
qemu/qemu.go
Outdated
|
|
||
| devParams = append(devParams, fmt.Sprintf("virtio-scsi-pci,id=%s", scsiCon.ID)) | ||
| if runtime.GOARCH == "s390x" { | ||
| devParams = append(devParams, fmt.Sprintf("%s,id=%s", VirtioSCSI, scsiCon.ID)) |
There was a problem hiding this comment.
you don't need the if-else you use the same variable. Actually, the two lines are the same
qemu/qemu.go
Outdated
| var devParams []string | ||
|
|
||
| devParams = append(devParams, fmt.Sprintf("virtio-scsi-pci,id=%s", scsiCon.ID)) | ||
| if runtime.GOARCH == "s390x" { |
There was a problem hiding this comment.
now I think this condition is not required, since VirtioSCSI changes its values at init() if runtime.GOARCH == "s390x", right?
qemu/qemu.go
Outdated
| // -pci devices don't play well with Z hence replace them with corresponding -ccw devices | ||
| // See https://wiki.qemu.org/Documentation/Platforms/S390X | ||
| func init() { | ||
| if runtime.GOARCH == "s390x" { |
There was a problem hiding this comment.
I think this is a very bad idea. We should use the generic versions for all those that have aliases in QEMU. Those that don't should be managed explicitly.
There was a problem hiding this comment.
Actually the QEMU team is planning on deprecating those alias in favour of the -ccw alternatives. Hence this was done.
There was a problem hiding this comment.
@rbradford Keeping them to -ccw would also allow us to have better ABI compatibility
There was a problem hiding this comment.
@rbradford @devimc Do you still want me to make this change?
qemu/qemu.go
Outdated
|
|
||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) | ||
| if runtime.GOARCH != "s390x" { | ||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) |
There was a problem hiding this comment.
Let's wait for @markdryan or @rbradford to comment here, but I'd be tempted to remove all these 390-specific if tests and create qemu_s390x.go like we do in the runtime:
To minimise code duplication, you can create generic functions and variables that all other arches can call.
qemu/qemu.go
Outdated
| type DeviceDriver string | ||
|
|
||
| const ( | ||
| var ( |
There was a problem hiding this comment.
Please don't remove the const here 😄
There was a problem hiding this comment.
I am setting the value of these variables at runtime. So making them const is not really possible.
However, since you and others have raised concerns with this and the arch specific if-else, let me just refactor this into a separate file.
|
@devimc @jodh-intel @rbradford PTAL. |
jodh-intel
left a comment
There was a problem hiding this comment.
Thanks for the update @ydjainopensource!
Let's get more input from @markdryan and @rbradford too...
qemu/qemu_generic.go
Outdated
| var deviceParams []string | ||
| var qemuParams []string | ||
|
|
||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) |
There was a problem hiding this comment.
This is the only difference between this function and the one in qemu_s390x.go so you could make this a generic function and define something like the following:
-
qemu_amd64.goconst vsockDevice = VhostVSOCKPCI -
qemu_s390x.goconst vsockDevice = VhostVSOCKCCW
... however, that would require you to create qemu_amd64.go of course :)
There was a problem hiding this comment.
@jodh-intel PCI is also used on ARM so this probably not you want.
| @@ -0,0 +1,127 @@ | |||
| // +build !s390x | |||
|
|
|||
| /* | |||
There was a problem hiding this comment.
Why the "double comments"? I'd remove the C-style comments from this file and qemu_s390x.go as they are redundant.
There was a problem hiding this comment.
For some mysterious reasons, the go build tool fails to build without this on my instances hence I have kept them
qemu/qmp.go
Outdated
| "addr": addr, | ||
| } | ||
|
|
||
| if runtime.GOARCH == "s390x" { |
There was a problem hiding this comment.
Again, for consistency with the qemu*.go files, I'd rework this as follows:
-
Create
qmp_amd64.goandqmp_s390x.gocontaining their own implementations of:var archPCIVFIODeviceAddMap = map[string]interface{}{ ... } -
Make
qmp.goreference the right implementation. Something like:var pciVFIODeviceAddMap = archPCIVFIODeviceAddMap func (q *QMP) ExecutePCIVFIODeviceAdd(...) { arg := archPCIVFIODeviceAddMap return q.executeCommand(ctx, "device_add", args, nil) }
rbradford
left a comment
There was a problem hiding this comment.
This is looking a lot better. Thank you for your diligence.
qemu/qemu_generic.go
Outdated
| var deviceParams []string | ||
| var qemuParams []string | ||
|
|
||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) |
There was a problem hiding this comment.
@jodh-intel PCI is also used on ARM so this probably not you want.
| VirtioSerialPort DeviceDriver = "virtserialport" | ||
|
|
||
| // VHostVSockPCI is the vhost vsock pci driver. | ||
| VHostVSockPCI DeviceDriver = "vhost-vsock-ccw" |
There was a problem hiding this comment.
This grates me. But I understand why you did it. Maybe we could transition all the users to a more generic name and eventually get rid of this?
There was a problem hiding this comment.
Add a new variable VhostVSOCK...where do I include the deprecation notice?
|
@devimc @rbradford @jodh-intel PTAL. |
|
All tests have passed now 🙂 |
qemu/qemu_s390x_test.go
Outdated
|
|
||
| // -pci devices don't play well with Z hence replace them with corresponding -ccw devices | ||
| // See https://wiki.qemu.org/Documentation/Platforms/S390X | ||
| func init() { |
There was a problem hiding this comment.
please remove this function, declare these variables
var deviceFSString = "-device virtio-9p-ccw,disable-modern=true,fsdev=workload9p,mount_tag=rootfs -fsdev local,id=workload9p,path=/var/lib/docker/devicemapper/mnt/e31ebda2,security_model=none"
var deviceNetworkString = "-netdev tap,id=tap0,vhost=on,ifname=ceth0,downscript=no,script=no -device driver=virtio-net,netdev=tap0,mac=01:02:de:ad:be:ef,disable-modern=true"
....and move the declaration of these variables from qemu_test.go to qemu_generic_test.go
qemu/qemu_test.go
Outdated
|
|
||
| // -pci devices don't play well with Z hence replace them with corresponding -ccw devices | ||
| // See https://wiki.qemu.org/Documentation/Platforms/S390X | ||
| func init() { |
|
|
||
| //VhostUserBlk represents a block vhostuser device type | ||
| VhostUserBlk = "vhost-user-blk-pci" | ||
|
|
There was a problem hiding this comment.
Could you remove this constant? There is no support for vhost-user devices and you could throw an error if the case is hit. You already split the s390x code, so you can set that explicitly
| case VFIO: | ||
| return string(Vfio) // -device vfio-pci (no netdev) or vfio-ccw on Z | ||
| case VHOSTUSER: | ||
| return "" // -netdev type=vhost-user (no device) |
There was a problem hiding this comment.
Could you print an error message if this case is hit?
|
@rbradford @devimc PTAL |
qemu/qemu_generic.go
Outdated
| case VETHTAP: | ||
| return string(VirtioNet) | ||
| case VFIO: | ||
| return string(VirtioNet) |
Signed-off-by: Yash Jain <ydjainopensource@gmail.com>
| ) | ||
|
|
||
| // QemuDeviceParam converts to the QEMU -device parameter notation | ||
| func (n NetDeviceType) QemuDeviceParam() string { |
There was a problem hiding this comment.
now this function is the same than the function in qemu_generic.go, can you move it to qemu.go ?
There was a problem hiding this comment.
I had by by mistake changed this. Now I have reverted to the correct version. Sorry for the inconvenience
There was a problem hiding this comment.
@devimc I have already repushed with the changes. PTAL
There was a problem hiding this comment.
sorry, I don't find any difference between this function and the function in qemu_generic.go (QemuDeviceParam), can you please factorize them?
| } | ||
|
|
||
| // QemuParams returns the qemu parameters built out of the VSOCK device. | ||
| func (vsock VSOCKDevice) QemuParams(config *Config) []string { |
There was a problem hiding this comment.
I don't understand this change , did you just move the function? if this is the case could you please revert it?
There was a problem hiding this comment.
@devimc Z does not support vhost-user-blk device so this test was oved into qemu_generic_test.go and qemu_s390x_test.go. With suitable changes applied.
| var deviceParams []string | ||
| var qemuParams []string | ||
|
|
||
| deviceParams = append(deviceParams, fmt.Sprintf("%s", VhostVSOCKPCI)) |
There was a problem hiding this comment.
I guess the change was VhostVSOCKPCI to VhostVSOCK right?, if that's correct could you please just change this line and not all the function, since it's not easy to read and detect the change
markdryan
left a comment
There was a problem hiding this comment.
Sorry, it's taken me so long to look at this. I've made a few small comments to the PR, but in general I have one large comment. Our contribution guidelines require all commits to have a commit body which explains what the commit actually does and why it's needed. In this case, such a description is really needed. I found it hard to review the PR as I don't really understand the context. Why is it needed? Why are these specific changes required? Some of this information is covered in comments in the PR but it really needs to go in the commit message.
Could you add a description to the commit message? Once it's added I'll take a more detailed look at the PR.
| devParams = append(devParams, "logical_block_size=4096") | ||
| devParams = append(devParams, "size=512M") | ||
| devParams = append(devParams, fmt.Sprintf("chardev=%s", vhostuserDev.CharDevID)) | ||
| if (VhostUserBlk) != "" { |
There was a problem hiding this comment.
There's no need for the brackets here. Also it's more idiomatic to write
if VhostUserBlk == "" {
return
}
devParams = append(devParams, VhostUserBlk)
...
|
|
||
| /* | ||
| // Copyright (c) 2018 Yash Jain | ||
| // |
There was a problem hiding this comment.
Didn't some, if not all of the code in this file come qemu.go? If so, we should "Copyright (c) 2016 Intel Corporation" in the comments.
| var deviceParam string | ||
|
|
||
| deviceParam := fmt.Sprintf("vfio-pci,host=%s", vfioDev.BDF) | ||
| deviceParam = fmt.Sprintf("%s,host=%s", Vfio, vfioDev.BDF) |
There was a problem hiding this comment.
You could just write deviceParam := fmt.Sprintf(
and delete the var deviceParam string declaration.
| // limitations under the License. | ||
| */ | ||
|
|
||
| // Package qemu provides methods and types for launching and managing QEMU |
There was a problem hiding this comment.
I don't think it makes sense to duplicate this comment. It's still present in qemu.go and will just make the godoc look weird if we duplicate it. Please delete it.
| @@ -0,0 +1,97 @@ | |||
| // +build !s390x | |||
There was a problem hiding this comment.
The naming of this file is a bit weird. Generic to me suggests that the code is suitable for all platforms but if I read the build constraint correctly, this code will not compile of s390, so it's not generic. Having said that I'm not quite sure what to call it right now as I'm lacking some context about this PR. I'll comment on this a little later.
| @@ -1,4 +1,5 @@ | |||
| /* | |||
| // Copyright (c) 2018 Yash Jain | |||
There was a problem hiding this comment.
I'm not really the best person to comment on this but you haven't actually added any code to this file. You've just deleted stuff. Hence I find the change to the copyright a little confusing. Anyone else care to comment?
|
|
||
| // -pci devices don't play well with Z hence corresponding -ccw devices | ||
| // See https://wiki.qemu.org/Documentation/Platforms/S390X | ||
| const ( |
There was a problem hiding this comment.
I don't understand why we are duplicating all of these constants. How many of them differ between s390 and non s390. Is it just the pci devices? If so we only need these guys to be separated out.
|
@markdryan @devimc @rbradford Unfortunately, I am at the end of my internship and hence won't be able to work on this further. Someone from IBM would be continuing from where I left. With that said, I am closing this PR. Thanks a lot for your time and patience. |
|
@ydjainopensource sad to hear that, thank you for your time and the contributions you did 👍 |
|
@ydjainopensource thank you for your contributions. Your PR initiated lots of interesting discussions. |
Fixes #37
Signed-off-by: Yash Jain ydjainopensource@gmail.com