-
Notifications
You must be signed in to change notification settings - Fork 669
Refactor: Decouple Qemu Internal from pkg/instance
#3377
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
Conversation
pkg/driver/driver.go
Outdated
@@ -71,6 +71,8 @@ type Driver interface { | |||
|
|||
// GuestAgentConn returns the guest agent connection, or nil (if forwarded by ssh). | |||
GuestAgentConn(_ context.Context) (net.Conn, error) | |||
|
|||
CheckBinarySignature(_ context.Context, arch string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be probably just merged to the existing Validate()
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AkihiroSuda I did what you suggested. What about this?
the "github.com/lima-vm/lima/pkg/qemu" is also present in cmd/limactl/disk.go file and "github.com/lima-vm/lima/pkg/qemu/imgutil" in pkg/store/disk.go file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disk image operation seems another aspect and can be visited later.
Rather we should concentrate on decoupling pkg/limayaml
from the VM drivers.
Quite complicated though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AkihiroSuda I went through the VM drivers code to decouple limayaml
. I see primarily constants like limayaml.VIRTIOFS
, limayaml.WSLMount
and functions like limayaml.MACAddress()
, limayaml.FirstUsernetIndex()
etc. What should be my approach here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limayaml.VIRTIOFS, limayaml.WSLMount
Eventually these should be defined in VM drivers, probably in another PR.
VIRTIOFS
will be duplicated in qemu
, vz
, and potentially more drivers
limayaml.MACAddress(), limayaml.FirstUsernetIndex() etc.
No need to split from limayaml
, as they do not depend on the implementation details of the VM drivers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/qemu/qemu_driver.go
Outdated
@@ -50,6 +50,25 @@ func New(driver *driver.BaseDriver) *LimaQemuDriver { | |||
} | |||
|
|||
func (l *LimaQemuDriver) Validate() error { | |||
// Ask the user to sign the qemu binary with the "com.apple.security.hypervisor" if needed. | |||
// Workaround for https://github.com/lima-vm/lima/issues/1742 | |||
if runtime.GOOS == "darwin" && l.BaseDriver.Instance.VMType == limayaml.QEMU { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VMType == QEMU
is always true here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also squash the commits
pkg/qemu/qemu_driver.go
Outdated
@@ -411,25 +430,6 @@ func (l *LimaQemuDriver) GuestAgentConn(ctx context.Context) (net.Conn, error) { | |||
return dialContext, err | |||
} | |||
|
|||
func (l *LimaQemuDriver) CheckBinarySignature(_ context.Context, arch string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For readability you can just keep this function with privatization (Check...
-> check...
), and call it from Validate()
31adc47
to
e1b3f85
Compare
e1b3f85
to
aa4d9e9
Compare
Still draft? |
Im little confused here what should be my approach? Any guidance is much appreciated then I can proceed with the PR. |
@AkihiroSuda Are you implying to decouple
|
qemu.go may continue to refer to limayaml, but limayaml shouldn't contain the details of qemu |
f624ab0
to
960d2a3
Compare
@AkihiroSuda I've tried to move the cpuType to |
pkg/limayaml shouldn't depend on pkg/qemu. |
Is there any more work remaining on this PR, such as decoupling qemu from the disk operations, or should I open it for review? |
960d2a3
to
8b9e9ad
Compare
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
8b9e9ad
to
3322d95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ready to merge as-is
WIP
This PR fixes #1746.