Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate qemu vm uuid #754

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

generate qemu vm uuid #754

wants to merge 1 commit into from

Conversation

dictcp
Copy link

@dictcp dictcp commented Mar 24, 2022

Background

Some application may requires the product_uuid from sysfs, OR it will be broken, eg.

The patch will generate a UUID, based of the MD5 sum of the VM name, and append as qemu --uuid parameter.
It should be safe and no impact to others usecase.

@AkihiroSuda AkihiroSuda added enhancement New feature or request component/qemu QEMU labels Mar 24, 2022
@@ -425,6 +427,7 @@ func Cmdline(cfg Config) (string, []string, error) {

// QEMU process
args = append(args, "-name", "lima-"+cfg.Name)
args = append(args, "-uuid", uuid.NewMD5(uuid.NameSpaceOID, []byte(cfg.Name)).String() )
Copy link
Member

Choose a reason for hiding this comment

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

For universal uniqueness, can we generate a random UUID and save it as “uuid” file in the instance dir?

// Filenames that may appear under an instance directory
const (
LimaYAML = "lima.yaml"
CIDataISO = "cidata.iso"
BaseDisk = "basedisk"
DiffDisk = "diffdisk"
QemuPID = "qemu.pid"
QMPSock = "qmp.sock"
SerialLog = "serial.log"
SerialSock = "serial.sock"
SSHSock = "ssh.sock"
GuestAgentSock = "ga.sock"
HostAgentPID = "ha.pid"
HostAgentSock = "ha.sock"
HostAgentStdoutLog = "ha.stdout.log"
HostAgentStderrLog = "ha.stderr.log"
// SocketDir is the default location for forwarded sockets with a relative paths in HostSocket
SocketDir = "sock"
)

Copy link
Member

Choose a reason for hiding this comment

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

( no need to save the uuid as a file if you adopt Jan’s approach #754 (comment) )

@AkihiroSuda
Copy link
Member

Thanks, but please sign the commit for DCO
https://github.com/apps/dco

(run git commit -a -s --amend, and make sure that the Signed-off-by: NAME <EMAIL> line with your real name is included in the commit message)

@jandubois
Copy link
Member

jandubois commented Mar 24, 2022

To have a globally unique, but persistent (accross VM restarts) id we include both the machine id and the full path to the VM directory:

sha := sha256.Sum256([]byte(osutil.MachineID() + uniqueID))

The instance name alone isn't even locally unique because you can have multiple LIMA_HOME settings on the same machine.

I would suggest to extract the sha function from limayaml.MACAddress into a separate function and also use it as input for the qemu UUID. The uniqueID passed into the function is the instance directory.

@junnplus
Copy link
Contributor

@dictcp Hi, are you still working on this PR? I need it too.

@AkihiroSuda
Copy link
Member

@junnplus Feel free to open a new PR to carry this (if you would like to)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/qemu QEMU enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants