Skip to contentSkip to conversation

virt: acrn: Mark the uuid field as unused

PATCH Superseded Andy Shevchenko 3 participants 10 messages Nov 16, 2022 – Nov 17, 2022 Acrn hypervisor service module

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 virt: acrn: Mark the uuid field as unused

After the commits for userspace (see Link tags below) the uuid field is not being used in the ACRN code. Update kernel to reflect these changes. I.e. we do the following:
- adding a comment explaining that it's not used anymore
- replacing the specific type by a raw buffer
- updating the example code accordingly

The advertised field confused users and actually never been used. So the wrong part here is that kernel puts something which userspace never used and hence this may confuse a reader of this code.

Fixes 5b06931d7f8b ("sample/acrn: Introduce a sample of HSM ioctl interface usage")
Fixes 9c5137aedd11 ("virt: acrn: Introduce VM management interfaces")

---
v4: added tag (Rafael), Cc'ed to Greg (missing in the previous version
by some reason)
v3: converted to Link tags (Rafael), explained what was wrong (Rafael)
v2: added tag (Fei)

 include/uapi/linux/acrn.h | 5 ++---
 samples/acrn/vm-sample.c  | 3 ---
 2 files changed, 2 insertions(+), 6 deletions(-)
include/uapi/linux/acrn.h +2 -3
index ccf47ed92500..04fa83647ae5 100644
@@ -12,7 +12,6 @@
 #define _UAPI_ACRN_H
 
 #include <linux/types.h>
-#include <linux/uuid.h>
 
 #define ACRN_IO_REQUEST_MAX		16
 
@@ -186,7 +185,7 @@ struct acrn_ioreq_notify {
  * @reserved0:		Reserved and must be 0
  * @vcpu_num:		Number of vCPU in the VM. Return from hypervisor.
  * @reserved1:		Reserved and must be 0
- * @uuid:		UUID of the VM. Pass to hypervisor directly.
+ * @uuid:		Reserved (used to be UUID of the VM)
  * @vm_flag:		Flag of the VM creating. Pass to hypervisor directly.
  * @ioreq_buf:		Service VM GPA of I/O request buffer. Pass to
  *			hypervisor directly.
@@ -198,7 +197,7 @@ struct acrn_vm_creation {
 	__u16	reserved0;
 	__u16	vcpu_num;
 	__u16	reserved1;
-	guid_t	uuid;
+	__u8	uuid[16];
 	__u64	vm_flag;
 	__u64	ioreq_buf;
 	__u64	cpu_affinity;
samples/acrn/vm-sample.c +0 -3
index b2dad47a77a0..7abd68b20153 100644
@@ -29,8 +29,6 @@ static struct acrn_io_request *io_req_buf = (struct acrn_io_request *)io_request
 
 __u16 vcpu_num;
 __u16 vmid;
-/* POST_STANDARD_VM_UUID1, refer to https://github.com/projectacrn/acrn-hypervisor/blob/master/hypervisor/include/common/vm_uuids.h */
-guid_t vm_uuid = GUID_INIT(0x385479d2, 0xd625, 0xe811, 0x86, 0x4e, 0xcb, 0x7a, 0x18, 0xb3, 0x46, 0x43);
 
 int hsm_fd;
 int is_running = 1;
@@ -63,7 +61,6 @@ int main(int argc, char **argv)
 	}
 	hsm_fd = open("/dev/acrn_hsm", O_RDWR|O_CLOEXEC);
 
-	memcpy(&create_vm.uuid, &vm_uuid, 16);
 	create_vm.ioreq_buf = (__u64)io_req_buf;
 	ret = ioctl(hsm_fd, ACRN_IOCTL_CREATE_VM, &create_vm);
 	printf("Created VM! [%d]\n", ret);
Signature · 1 line
2.35.1
#1 lore raw
Quoted 40 lines · Andy Shevchenko

After the commits for userspace (see Link tags below) the uuid field is not being used in the ACRN code. Update kernel to reflect these changes. I.e. we do the following:
- adding a comment explaining that it's not used anymore
- replacing the specific type by a raw buffer
- updating the example code accordingly

The advertised field confused users and actually never been used. So the wrong part here is that kernel puts something which userspace never used and hence this may confuse a reader of this code.

Fixes 5b06931d7f8b ("sample/acrn: Introduce a sample of HSM ioctl interface usage")
Fixes 9c5137aedd11 ("virt: acrn: Introduce VM management interfaces")

---
v4: added tag (Rafael), Cc'ed to Greg (missing in the previous version
by some reason)
v3: converted to Link tags (Rafael), explained what was wrong (Rafael)
v2: added tag (Fei)

 include/uapi/linux/acrn.h | 5 ++---
 samples/acrn/vm-sample.c  | 3 ---
 2 files changed, 2 insertions(+), 6 deletions(-)
include/uapi/linux/acrn.h +0 -1
index ccf47ed92500..04fa83647ae5 100644
@@ -12,7 +12,6 @@
 #define _UAPI_ACRN_H
 
 #include <linux/types.h>
-#include <linux/uuid.h>
 
 #define ACRN_IO_REQUEST_MAX		16
 

include/uapi/linux/acrn.h struct acrn_ioreq_notify { · line 188

Quoted 5 lines
include/uapi/linux/acrn.h +1 -1
@@ -186,7 +185,7 @@ struct acrn_ioreq_notify {
  * @reserved0:		Reserved and must be 0
  * @vcpu_num:		Number of vCPU in the VM. Return from hypervisor.
  * @reserved1:		Reserved and must be 0
- * @uuid:		UUID of the VM. Pass to hypervisor directly.
+ * @uuid:		Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 9 lines
include/uapi/linux/acrn.h +1 -1
  * @vm_flag:		Flag of the VM creating. Pass to hypervisor directly.
  * @ioreq_buf:		Service VM GPA of I/O request buffer. Pass to
  *			hypervisor directly.
@@ -198,7 +197,7 @@ struct acrn_vm_creation {
 	__u16	reserved0;
 	__u16	vcpu_num;
 	__u16	reserved1;
-	guid_t	uuid;
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

And no other kernel changes needed? Shouldn't you warn if this field is set?

thanks,

greg k-h

#2 lore raw
Quoted 8 lines · Greg Kroah-Hartman
Quoted 7 lines · Andy Shevchenko

After the commits for userspace (see Link tags below) the uuid field is not being used in the ACRN code. Update kernel to reflect these changes. I.e. we do the following:
- adding a comment explaining that it's not used anymore
- replacing the specific type by a raw buffer
- updating the example code accordingly

Quoted 8 lines
Quoted 6 lines

The advertised field confused users and actually never been used. So the wrong part here is that kernel puts something which userspace never used and hence this may confuse a reader of this code.

- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

Reserved in a way that it may content something we just don't care about.

...

Quoted 5 lines

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 1 line
include/uapi/linux/acrn.h +1 -0
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

It's the same. The previous was hidden behind additional type level.

Quoted 2 lines

And no other kernel changes needed? Shouldn't you warn if this field is set?

No, as pointed out in the commit message kernel never ever used this.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Andy Shevchenko

After the commits for userspace (see Link tags below) the uuid field is not being used in the ACRN code. Update kernel to reflect these changes. I.e. we do the following:
- adding a comment explaining that it's not used anymore
- replacing the specific type by a raw buffer
- updating the example code accordingly

The advertised field confused users and actually never been used. So the wrong part here is that kernel puts something which userspace never used and hence this may confuse a reader of this code.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

Reserved in a way that it may content something we just don't care about.

"reserved" in the kernel ioctls mean "must be 0 and we will test for it, otherwise this is an empty/useless field that can never be touched again in the future.

Please spell it out in detail as to if you can ever use this later on, and what the kernel will do (if anything) if it is set.

And if "the kernel ignores it" then that means these bytes are now "empty space never to be used again", right?

Quoted 9 lines

...

Quoted 5 lines

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 1 line
include/uapi/linux/acrn.h +1 -0
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

It's the same. The previous was hidden behind additional type level.

Same size, yes. Same C structure definition, no.

Quoted 4 lines
Quoted 2 lines

And no other kernel changes needed? Shouldn't you warn if this field is set?

No, as pointed out in the commit message kernel never ever used this.

That does not mean that userspace tools never did, right? You are changing the structure definition, what tool just broke?

thanks,

greg k-h

#4 lore raw
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg Kroah-Hartman

On Wed, Nov 16, 2022 at 11:22:54AM +0200, Andy Shevchenko wrote:

...

Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

Reserved in a way that it may content something we just don't care about.

"reserved" in the kernel ioctls mean "must be 0 and we will test for it, otherwise this is an empty/useless field that can never be touched again in the future.

Quoted 5 lines

Please spell it out in detail as to if you can ever use this later on, and what the kernel will do (if anything) if it is set.

And if "the kernel ignores it" then that means these bytes are now "empty space never to be used again", right?

Right, I will fix this in v5.

...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 1 line
include/uapi/linux/acrn.h +1 -0
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

It's the same. The previous was hidden behind additional type level.

Same size, yes. Same C structure definition, no.

It doesn't matter, see below.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

And no other kernel changes needed? Shouldn't you warn if this field is set?

No, as pointed out in the commit message kernel never ever used this.

That does not mean that userspace tools never did, right? You are changing the structure definition, what tool just broke?

The only tool has been amended like a year ago, so the answer is none. The commit message has links to the commits in question that made that amendment.

Maybe I should remove Fixes tags? In such case we will very much know that no old tools will be run on the new kernel.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
Quoted 48 lines · Andy Shevchenko
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg Kroah-Hartman

On Wed, Nov 16, 2022 at 11:22:54AM +0200, Andy Shevchenko wrote:

...

Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

Reserved in a way that it may content something we just don't care about.

"reserved" in the kernel ioctls mean "must be 0 and we will test for it, otherwise this is an empty/useless field that can never be touched again in the future.

Quoted 5 lines

Please spell it out in detail as to if you can ever use this later on, and what the kernel will do (if anything) if it is set.

And if "the kernel ignores it" then that means these bytes are now "empty space never to be used again", right?

Right, I will fix this in v5.

...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 1 line
include/uapi/linux/acrn.h +1 -0
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

It's the same. The previous was hidden behind additional type level.

Same size, yes. Same C structure definition, no.

It doesn't matter, see below.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

And no other kernel changes needed? Shouldn't you warn if this field is set?

No, as pointed out in the commit message kernel never ever used this.

That does not mean that userspace tools never did, right? You are changing the structure definition, what tool just broke?

Quoted 6 lines

The only tool has been amended like a year ago, so the answer is none. The commit message has links to the commits in question that made that amendment.

Maybe I should remove Fixes tags? In such case we will very much know that no old tools will be run on the new kernel.

Please remove "fixes" as this doesn't "fix" anything.

thanks,

greg k-h

#6 lore raw
Quoted 49 lines · Greg Kroah-Hartman
Quoted 48 lines · Andy Shevchenko
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg Kroah-Hartman

On Wed, Nov 16, 2022 at 11:22:54AM +0200, Andy Shevchenko wrote:

...

Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

Reserved in a way that it may content something we just don't care about.

"reserved" in the kernel ioctls mean "must be 0 and we will test for it, otherwise this is an empty/useless field that can never be touched again in the future.

Quoted 5 lines

Please spell it out in detail as to if you can ever use this later on, and what the kernel will do (if anything) if it is set.

And if "the kernel ignores it" then that means these bytes are now "empty space never to be used again", right?

Right, I will fix this in v5.

...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 1 line
include/uapi/linux/acrn.h +1 -0
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

It's the same. The previous was hidden behind additional type level.

Same size, yes. Same C structure definition, no.

It doesn't matter, see below.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

And no other kernel changes needed? Shouldn't you warn if this field is set?

No, as pointed out in the commit message kernel never ever used this.

That does not mean that userspace tools never did, right? You are changing the structure definition, what tool just broke?

Quoted 8 lines
Quoted 6 lines

The only tool has been amended like a year ago, so the answer is none. The commit message has links to the commits in question that made that amendment.

Maybe I should remove Fixes tags? In such case we will very much know that no old tools will be run on the new kernel.

Please remove "fixes" as this doesn't "fix" anything.

Done in v5.

Thank you for the thorough review!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#7 lore raw
In reply to Andy Shevchenko
Quoted 18 lines · Andy Shevchenko
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Greg Kroah-Hartman

On Wed, Nov 16, 2022 at 11:22:54AM +0200, Andy Shevchenko wrote:

...

Quoted 11 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Reserved (used to be UUID of the VM)

If it's reserved, then don't you need to check for 0?

Reserved in a way that it may content something we just don't care about.

"reserved" in the kernel ioctls mean "must be 0 and we will test for it, otherwise this is an empty/useless field that can never be touched again in the future.

Quoted 7 lines
Quoted 5 lines

Please spell it out in detail as to if you can ever use this later on, and what the kernel will do (if anything) if it is set.

And if "the kernel ignores it" then that means these bytes are now "empty space never to be used again", right?

Right, I will fix this in v5.

Hi Andy

ACRN does not use uuid recently. But before that, the old ACRN still uses it. So could we just change the uuid data structure definition here ?

Thanks.

Quoted 35 lines

...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

include/uapi/linux/acrn.h struct acrn_vm_creation { · line 200

Quoted 1 line
include/uapi/linux/acrn.h +1 -0
+	__u8	uuid[16];

You just changed the type here, so what is that going to break in userspace that depended on this being of a structure type and now it's an array?

It's the same. The previous was hidden behind additional type level.

Same size, yes. Same C structure definition, no.

It doesn't matter, see below.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

And no other kernel changes needed? Shouldn't you warn if this field is set?

No, as pointed out in the commit message kernel never ever used this.

That does not mean that userspace tools never did, right? You are changing the structure definition, what tool just broke?

The only tool has been amended like a year ago, so the answer is none. The commit message has links to the commits in question that made that amendment.

Maybe I should remove Fixes tags? In such case we will very much know that no old tools will be run on the new kernel.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
Quoted 1 line · Fei Li

On 2022-11-16 at 18:04:37 +0200, Andy Shevchenko wrote:

...

Quoted 2 lines

ACRN does not use uuid recently. But before that, the old ACRN still uses it. So could we just change the uuid data structure definition here ?

That's what is meant by removing the Fixes tags.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Fei Li

On 2022-11-16 at 18:04:37 +0200, Andy Shevchenko wrote:

...

Quoted 4 lines
Quoted 2 lines

ACRN does not use uuid recently. But before that, the old ACRN still uses it. So could we just change the uuid data structure definition here ?

That's what is meant by removing the Fixes tags.

Note, this change also removes the link to non-existing file.

Signature · 2 lines
With Best Regards,
Andy Shevchenko