From 47691fae67730f49401458108b84ca6965202f1d Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Tue, 8 Feb 2022 12:29:17 +0800 Subject: [PATCH] fix(host): dist prepare migrate_certs --- .../guestman/guesthandlers/guesthandler.go | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/hostman/guestman/guesthandlers/guesthandler.go b/pkg/hostman/guestman/guesthandlers/guesthandler.go index a647276f47..1c5cfcb3f9 100644 --- a/pkg/hostman/guestman/guesthandlers/guesthandler.go +++ b/pkg/hostman/guestman/guesthandlers/guesthandler.go @@ -311,16 +311,18 @@ func guestDestPrepareMigrate(ctx context.Context, sid string, body jsonutils.JSO params.QemuVersion = qemuVersion params.LiveMigrate = liveMigrate params.SourceQemuCmdline = qemuCmdline - certsObj, err := body.Get("migrate_certs") - if err != nil { - return nil, httperrors.NewMissingParameterError("migrate_certs") - } - certs := map[string]string{} - if err := certsObj.Unmarshal(&certs); err != nil { - return nil, httperrors.NewInputParameterError("unmarshal migrate_certs to map: %s", err) - } - params.MigrateCerts = certs params.EnableTLS = jsonutils.QueryBoolean(body, "enable_tls", false) + if params.EnableTLS { + certsObj, err := body.Get("migrate_certs") + if err != nil { + return nil, httperrors.NewMissingParameterError("migrate_certs") + } + certs := map[string]string{} + if err := certsObj.Unmarshal(&certs); err != nil { + return nil, httperrors.NewInputParameterError("unmarshal migrate_certs to map: %s", err) + } + params.MigrateCerts = certs + } if isLocal { serverUrl, err := body.GetString("server_url") if err != nil {