qemu-kvm串口功能代码调试随笔

由于最近需要使用qemu的宿主机-客户机 串口映射功能(但还未找到合适方式),便开始学习这部分代码

首先,搭建vscode debug 环境:

  1. 打开qemu源码路径,
  2. 创建./bin/debug/文件路径并进入
  3. 配置并编译
    ../../configure --target-list=x86_64-softmmu --enable-kvm --disable-sdl --enable-linux-aio --enable-debug --enable-debug-info
    make -j4
  4. 替换 项目路径下的.vscode 下的 launch.json ,内容如下:
    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "qemu",
                "type": "cppdbg",
                "request": "launch",
                "program": "${workspaceFolder}/bin/debug/x86_64-softmmu/qemu-system-x86_64",
                "args": [
                    "-boot", //-boot c 启动第一个硬盘
                    "c",
                    "-drive",
                    "file=./debian_squeeze_amd64_standard.qcow2,if=virtio",
                    //-drive file=debian_squeeze_amd64_standard.qcow2,if=virtio
                    //指定硬盘镜像为debian_squeeze_amd64_standard.qcow2,
                    //同时指定此硬盘的接入方式,即virtio,virtio是基于kvm实现的,因此需要开启kvm
                    "-net",
                    "nic",
                    "-net",
                    "user,hostfwd=tcp::22222-:22",
                    //-net nic -net user,hostfwd=tcp::22222-:22 
                    //配置虚拟网卡、网络栈权限为用户权限和端口映射
                    "-m",
                    "2G", // -m 2G 指定2G内存
                    "-nographic", //关闭图像功能
                    "-enable-kvm" //开启kvm加速
                ],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}/bin/debug/x86_64-softmmu/workdir",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    },
                    {
                        "description": "disable user defined signal",
                        "text": "handle SIGUSR1 SIGUSR2 noprint nostop",
                        "ignoreFailures": true
                    }
                ],
                "miDebuggerPath": "/usr/bin/gdb"
            }
        ]
    }

    这样qemu-system-x86_64的vscode调试环境便搭建好了,其中的debian_squeeze_amd64_standard.qcow2镜像是在网上下载的。配置文件后续还会修改,因为串口的参数未添加,会持续进行更新。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值